WCF - 在数据契约中使用泛型是否会使 WSDL 不可互操作?
基本上:
[DataContract(Namespace = "http://www.abc.com/foo" Name = "Get{0}Request")]
public class GetGenericRequest<T> { ... }
我的 WSDL 有这样的逐字记录:
<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"/>
所以,看起来这似乎并不具有互操作性。它有额外的“appinfo”内容,对于 Java 或 PHP 来说可能会出现问题,对吗?或者他们会忽略这一点?
另外,更奇怪的是,无论我使用 int[]
还是 ICollection
等,它仍然会生成 ArrayOfint
类型(其中,我知道它会将它理解的所有底层集合更改为数组,但是,该命名可以互操作吗?)
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?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它是可互操作的 - 对于客户端来说,就像您有一个名为
GetFooRequest
的非泛型类一样。至于集合,同样,名称并不(或不应该)重要,只要元素的架构符合即可。
的,是“标准”。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".