The proxy methods that I am seeing generated for methods that have generics for parameters like List Of <T>
are getting converted to arrays in the proxy methods. I am not sure what the problem is, is it that the wsdl.exe that shipped with Visual Studio 2005 can't handle generics, or is it the version of soap on the machine where the web service is deployed or something else? When I view the asmx file in IE 7, I see SOAP 1.1 I expected to see soap 1.2 but that could be an IE7 thing.
views:
437answers:
3WSDL.EXE and "Add Web Reference" will always use an array. This has nothing to do with generics.
When you upgrade to WCF, you'll be able to specify to use List<T>
for lists like this.
XML Schema has neither arrays nor lists, just repeated elements. For instance, if your service returns List<int>
, the XML Schema in the WSDL will be something like
<xs:element name="result" maxOccurs="unbounded" type="xs:int"/>
The program that creates the proxy class has to decide whether to translate this into arrays or lists. With "Add Web Reference", the choice is always "array". With "Add Service Reference", you get a number of choices, including List<int>
.
.NET's XmlSerializer serialized collections into arrays. I'm unfamiliar if there is any difference for Generic lists but I doubt so. As such SOAP "collections" are always .NET arrays, it's up to the generated proxy to restore the array to the proper collection type (which is really of it's choice).
One other side-effect of collections being serialized into arrays is that only the collection elements are serialized. For example, the below class inherits from a list and adds a new property which will not be serialized by the XmlSerializer, since arrays consist only of elements and not additional properties.
public class MyList : List
{
public string MyProperty{get;set;}
}
This behaviorism is specific to the XmlSerializer, binary serializers (and perhaps WCF's DataContractSerializer) can handle these conditions.