使用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>
Run Code Online (Sandbox Code Playgroud)
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
{
}
Run Code Online (Sandbox Code Playgroud)
我想知道如何定义类'Merchant'和'ArrayOfMerchant'.
谢谢.
Vik*_*tty 33
如果您随身携带了WSDL,则可以直接创建C#代理类.
下面提到的是其中一种方法.如果您的WSDL数据未通过URL公开.首先将可用的WSDL数据保存到文件中,说"D:\ MerchantService.wsdl"
svcutil.exe D:\MerchantService.wsdl /t:code /l:c# /o:"D:\MerchantService.cs" /n:*,NamespaceName
Run Code Online (Sandbox Code Playgroud)
参考:http://msdn.microsoft.com/en-us/library/aa347733.aspx
您的问题依赖于 XSD。svcutil 不支持 complexContent 标签内的限制:http : //msdn.microsoft.com/en-us/library/ms733112.aspx
msdn 说它实际上是被禁止的:

| 归档时间: |
|
| 查看次数: |
67838 次 |
| 最近记录: |