Converting WSDL classes to C #

Converting WSDL classes to C # using the microsoft net wsdl.exe utility, but the tool cannot convert the next part of the WSDL file. Any pointers in the right direction were highly 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 "Merchant" and "ArrayOfMerchant" classes.

Thanks.

+4
source share
2 answers

If you have WSDL, you will be interested in creating a C # proxy class.

Below is one way to do this. If your WSDL data is not displayed through the URL. First save the available WSDL data in a file, for example, "D: \ MerchantService.wsdl"

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

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

+21
source

Your problem is with the XSD. svcutil does not support restrictions inside the complexContent tag: http://msdn.microsoft.com/en-us/library/ms733112.aspx

msdn says this is not allowed:

enter image description here

+2
source

Source: https://habr.com/ru/post/1379227/


All Articles