[英]Converting WSDL to C# classes
使用 microsoft net wsdl.exe 工具将 WSDL 转换为 C# 类,但该工具无法转换 WSDL 文件的以下部分。 任何指向正确方向的指针都非常感谢。
WSDL 输入
<complexType name="Merchant">
<sequence>
<element name="iId" type="xsd:int" />
<element name="sName" type="xsd:string" />
<element name="sDescription" type="xsd:string" minOccurs="0" />
<element name="aSectors" type="api:ArrayOfMerchantSectors" minOccurs="0" />
</sequence>
</complexType>
<complexType name="ArrayOfMerchant">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="api:Merchant[]" />
</restriction>
</complexContent>
</complexType>
<complexType name="MerchantSector">
<sequence>
<element name="iSectorId" type="xsd:int" />
<element name="sSectorName" type="xsd:string" />
</sequence>
</complexType>
<complexType name="ArrayOfMerchantSectors">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="api:MerchantSector[]" />
</restriction>
</complexContent>
</complexType>
C# 输出 ?????
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://api.someexampledomain.com/")]
public partial class ArrayOfMerchant : Array
{
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://api.someexampledomain.com/")]
public partial class ArrayOfMerchantSectors : Array
{
}
我想知道如何定义“Merchant”和“ArrayOfMerchant”类。
谢谢。
如果您有 WSDL,那么创建 C# 代理类就很简单了。
下面提到的是一种方法。 如果您的 WSDL 数据不是通过 URL 公开的。 首先将可用的 WSDL 数据保存到一个文件中,比如“D:\\MerchantService.wsdl”
svcutil.exe D:\MerchantService.wsdl /t:code /l:c# /o:"D:\MerchantService.cs" /n:*,NamespaceName
您的问题依赖于 XSD。 svcutil 不支持 complexContent 标签内的限制: http : //msdn.microsoft.com/en-us/library/ms733112.aspx
msdn 说它实际上是被禁止的:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.