将 WSDL 转换为 C# 类 [英] Converting WSDL to C# classes

查看:27
本文介绍了将 WSDL 转换为 C# 类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 microsoft net wsdl.exe 工具将 WSDL 转换为 C# 类,但该工具无法转换 WSDL 文件的以下部分.任何指向正确方向的指针都非常感谢.

Converting WSDL to C# classes using microsoft net wsdl.exe tool but the tool is unable to convert the following part of the WSDL file. Any pointers in the right direction greatly appreciated.

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"类.

I would like to know how to define the class 'Merchant' and 'ArrayOfMerchant'.

谢谢.

推荐答案

如果您有 WSDL,那么创建 C# 代理类就很简单了.

If you got the WSDL with you it is straightforward to create the C# proxy class.

下面提到的是一种方法.如果您的 WSDL 数据不是通过 URL 公开的.首先将可用的 WSDL 数据保存到一个文件中,比如D:\MerchantService.wsdl"

Below mentioned is one of the way to do it. If your WSDL data is not exposed via a URL. First save the Available WSDL data into a file say "D:\MerchantService.wsdl"

svcutil.exe D:\MerchantService.wsdl /t:code /l:c# /o:"D:\MerchantService.cs" /n:*,NamespaceName 

参考:http://msdn.microsoft.com/en-us/图书馆/aa347733.aspx

这篇关于将 WSDL 转换为 C# 类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆