Martin Pedersen
Martin Pedersen

Reputation: 41

Svcutil Not Generating All Classes

I want to call an external SOAP service which i want to generate proxy classes for. The .wsdl is not exposed online, but provided alongside a set .xsd files. I'm then using svcutil (also tried with dotnet-svcutil 1.0.4) to generate the classes. Consider the following XML:

<xs:complexType name = "ValidationReply" abstract="false">
  <xs:complexContent>
    <xs:extension base="common:Reply">
      <xs:sequence>
        <xs:element name="data" type="ns:ValidationReplyData" minOccurs="0" maxOccurs="1"/>
      </xs:sequence>
    </xs:extension>
  </xs:complexContent>
</xs:complexType>
<xs:complexType name="ValidationReplyData" abstract="false">
  <xs:sequence>
    <xs:element name="errors" type="ns:Error" minOccurs="0" maxOccurs="unbounded"/>
  </xs:sequence>
</xs:complexType>

Generates the following code:

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("dotnet-svcutil", "1.0.4")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="Namespace")]
public partial class ValidationReply: Reply
{

    private Error[] dataField;

    /// <remarks/>
    [System.Xml.Serialization.XmlArrayAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)]
    [System.Xml.Serialization.XmlArrayItemAttribute("errors", Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=false)]
    public Error[] data
    {
        get
        {
            return this.dataField;
        }
        set
        {
            this.dataField = value;
        }
    }
}

The issue is that the XML defines an inner type containing the list of errors, where Svcutil puts the list of errors directly as the data field, instead making the data field of type ValidationReplyData. The ValidationReplyData is not generated at all.

The code compiles without any issues and i am able to call the external service without errors. The data field is however always null as the response is on the format:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
  <S:Body>
    <fl:ValidationReply xmlns:fw="Namespace" >
      <data>
        <errors>
          <code>236</code>
        </errors>
        <errors>
          <code>237</code>
        </errors>
      </data>
    </fl:ValidationReply>
  </S:Body>
</S:Envelope>

Which does not deserialize correctly to the generated class.

In short, does anyone know how to force Svcutil to generate all classes? Redundant or not.

I have simplified the xml snippets, so there may be some inconsistencies in the example, but the digest of the problem is the missing ValidationReplyData class-

Upvotes: 4

Views: 690

Answers (0)

Related Questions