Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

svcutil generated unneccesary wrapper classes

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

public partial class getDataByIdResponse1 {

    public getDataByIdResponse getDataByIdResponse;

    public getDataByIdResponse1() {
    }

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

The getDataByIdResponse is wrapped inside a getDataByIdResponse1 object. This is done by svcutil and I have no idea why. The getDataByIdResponse1 object does not exist in the 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 I should have used?

like image 249
user787312 Avatar asked Jun 07 '11 11:06

user787312


1 Answers

I'm in the same boat as you but I don't just want to live with it. I want to generate clean (unwrapped) contracts. If the wsdl and xsd's were given to you then there are some rules that your schema and wsdl need to follow in order for svc util to generate unwrapped code. These links helped me understand the issue a little better

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

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

For now my schema and wsdl are small enough that I can tweak them to adhere to this rules.
However, like Ron, I've also been in situations where the easiest thing is just to live with it.

Hope this helps.

like image 55
dalcantara Avatar answered Oct 05 '22 22:10

dalcantara