Svcutil generates non-zero wrapper classes

I am working on a project that uses the first contract approach. I was given WSDL and three xsd's . When I use svcutil , it generates a wrapper around the response class as follows:

 public partial class getDataByIdResponse1 { public getDataByIdResponse getDataByIdResponse; public getDataByIdResponse1() { } public getDataByIdResponse1(getDataByIdResponse getDataByIdResponse) { this.getDataByIdResponse = getDataByIdResponse; } } 

getDataByIdResponse terminates inside the getDataByIdResponse1 object. This is done by svcutil , and I have no idea why. The getDataByIdResponse1 object getDataByIdResponse1 not exist in WSDL :

 <wsdl:message name="getDataById"> <wsdl:part name="response" element="tns:getDataByIdResponse"/> </wsdl:message> <xs:element name="getDataByIdResponse"> <xs:complexType> <xs:sequence> <xs:element name="data" type="sbc:DataType" minOccurs="1" maxOccurs="1" /> </xs:sequence> </xs:complexType> </xs:element> 

Why is the type getDataByIdResponse wrapped in getDataByIdResponse1 ? Is there a switch for svcutil that I should have used?

+6
source share
2 answers

I am in the same situation (contract-first), and svcutil generates the same code for me, but I just closed my eyes, took a deep breath and accepted it :-)

Just use types without a numeric postfix, and it just works.

0
source

I am in the same boat as you, but I do not want to live with her. I want to create clean (expandable) contracts. If you were given wsdl and xsd, then there are a few rules that should follow your scheme and wsdl for svc to use to create the deployed code. These links helped me understand the problem a little better.

http://pzf.fremantle.org/2007/05/handlign.html

http://mharbauer.wordpress.com/2007/10/19/wcf-datacontract-serializer-and-documentwrapped/

So far, my schema and wsdl are small enough so that I can configure them to follow these rules.
However, like Ron, I was also in situations where it was easiest to live with him.

Hope this helps.

0
source

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


All Articles