WCF wsdl 字符串数组
如何告诉 WCF 使用 wsdl arrayType?像这样:
<complexType name="ArrayOfString">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="string[]"/>
</restriction>
</complexContent>
</complexType>
这就是 WCF 正在做的事情(不是预期的)
<complexType name="ArrayOfstring">
<sequence>
<element minOccurs="0" maxOccurs="unbounded" name="string" nillable="true" type="xs:string"/>
</sequence>
<element name="ArrayOfstring" nillable="true" type="tns:ArrayOfstring"/>
</complexType>
How do I tell WCF to make use of wsdl arrayType? Like this:
<complexType name="ArrayOfString">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="string[]"/>
</restriction>
</complexContent>
</complexType>
This is what WCF is doing (The not expected)
<complexType name="ArrayOfstring">
<sequence>
<element minOccurs="0" maxOccurs="unbounded" name="string" nillable="true" type="xs:string"/>
</sequence>
<element name="ArrayOfstring" nillable="true" type="tns:ArrayOfstring"/>
</complexType>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
找到了解决方案。我必须添加它才能使其工作: [XmlSerializerFormat(Style = OperationFormatStyle.Rpc, Use = OperationFormatUse.Encoded)]
Found the solution. I have to add this to make it work: [XmlSerializerFormat(Style = OperationFormatStyle.Rpc, Use = OperationFormatUse.Encoded)]
我认为 WCF 不支持开箱即用,因为这是数据类型的标准 XSD 描述的 WSDL 扩展。在完全不涉及 Web 服务的情况下,
XmlSerializer
和DataContractSerializer
都应该与标准 XSD 配合使用,因此它使用普通的 XSD 方法。如果您需要第一种方法,您可以自己编写 WSDL + XSD,也可以尝试实现自定义 导出扩展 - 要将其用于 WCF 客户端生成,您还需要自定义导入扩展。
I think WCF doesn't support it out of the box because that is WSDL extension to standard XSD description of data type. Both
XmlSerializer
andDataContractSerializer
should work with standard XSD in scenarios where web services are not involved at all so it uses the plain XSD approach.If you need the first approach you can either write WSDL + XSDs yourselves or you can try to implement custom export extension - to use that for WCF client generation you will also need custom import extension.