Search code examples
wcfgenericsinteropwsdldatacontract

WCF - Is using a generic in your datacontract going to make your WSDLs non-interoperable?


Basically:

[DataContract(Namespace = "http://www.abc.com/foo" Name = "Get{0}Request")]
public class GetGenericRequest<T> { ... }

my WSDL has this verbatum:

<xs:complexType name="GetFooRequest">
  <xs:annotation>
    <xs:appinfo>
      <GenericType xmlns="http://schemas.microsoft.com/2003/10/Serialization/" Name="Get{0}Request" Namespace="http://www.abc.com/foo">
        <GenericParameter Name="Foo" Namespace="http://www.abc.com/foo"/>
      </GenericType>
    </xs:appinfo>
  </xs:annotation>
  <xs:sequence>
    <xs:element xmlns:q2="http://schemas.microsoft.com/2003/10/Serialization/Arrays" minOccurs="0" name="Ids" nillable="true" type="q2:ArrayOfint"/>
  </xs:sequence>
</xs:complexType>
<xs:element name="GetFooRequest" nillable="true" type="tns:GetFooRequest"/>

So, looking at that it just does not seem that this would be interoperable. It has the extra "appinfo" stuff that would probably throw things off for Java or PHP right? or would they just ignore that?

Also, what's even more strange is that whether I use int[] or ICollection<int>, etc it still makes the type ArrayOfint (which, I get that it changes all underlying collections that it understands to an array. But, is that naming interoperable?)


Solution

  • It is interoperable - for clients it's just as if you have a non-generic class, named GetFooRequest. As for the collections, again, the name doesn't (or shouldn't) matter, as long as the schema of the element <xs:sequence> of <xs:int>, is "standard".