Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting WSDL to C# classes

Tags:

c#

soap

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 Input

<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# Output ?????

/// <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
{
}

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

Thanks.

like image 621
Steven Avatar asked Nov 01 '11 22:11

Steven


1 Answers

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

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 

Refrence : http://msdn.microsoft.com/en-us/library/aa347733.aspx

like image 137
Vikram Shetty Avatar answered Oct 24 '22 11:10

Vikram Shetty