Can I stop the service link generating an ArrayOfString instead of the string []?

I have a web method with this signature:

public string[] ToUpper(string[] values) 

I use the Add Service link in Visual Studio 2010 to create a link to my service. Unfortunately, this process creates a proxy class called "ArrayOfString" and uses this type instead of the expected type "string []". The generated async service call signature ends as follows:

 public void ToUpperAsync(Demo.ServiceReference.ArrayOfString values) { } public void ToUpperAsync(Demo.ServiceReference.ArrayOfString values, object userState) { } 

I tried all the “Collection” expansion options in the configuration service help form, and it doesn't seem to make a difference.

This worked previously, but for some reason it suddenly stopped working, possibly after removing another web method from the service.

How to get the created service reference class to use the string [] type instead of the generated ArrayOfString type? Any help on this would be greatly appreciated.

EDIT: As @Oleg suggests, I use ASMX web services.

+7
source share
3 answers

I can reproduce your problem by adding a "Service Link" to the ASMX style web service. However, when adding “Service refernce” to the WCF service or “web link” in the ASMX service argument, there was a string like [].

Accordingly, I think that you can fix your problem by replacing the Service link with the Web Link link.

Click the "More ..." button in the "Add Service Link Dialog". Add service reference

Click "Add Web Link ...". Advanced

Insert service url and add web link Add web reference

+5
source

this change in the XmlSerializer can be done inside the Reference.svcmap file. Open it in the Service Reference folder and replace the Serializer xml node with "Auto" with "XmlSerializer", this solves the problem! Greetings

+11
source

Too late, but may help people in the future ...

Use svcutil and explicitly tell the command line that you want the proxy class to be serialized by XmlSerializer , and not DataContractSerializer (by default). Here's a sample:

svcutil / out: c: \ Path \ Proxy.cs / config: c: \ Path \ Proxy.config / async / serializer: XmlSerializer / namespace: *, YourNamespace http://www.domain.com/service/serviceURL.asmx

Note that the web service is an ASP.NET web service ok ?!

+2
source

All Articles