Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
483 views
in Technique[技术] by (71.8m points)

c# - Can I stop service reference generating ArrayOfString instead of string[]?

I have a web method with a signature like this:

public string[] ToUpper(string[] values)

I am using the 'Add Service reference' in Visual Studio 2010 to generate a reference to my service. Unfortunately, this process creates a proxy class called 'ArrayOfString' and uses this type instead of the expected 'string[]' type. The generated async service call signature ends up looking like this:

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

I have tried all the options of the 'Collection' drop down on the config service reference form and it doesn't seem the make a difference.

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

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

this change to XmlSerializer can ben done inside the Reference.svcmap file. Open it inside the Service Reference folder and change the Serializer xml node from "Auto" to "XmlSerializer" this solves the problem! Cheers


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...