Error creating valid proxy objects from WSDL

I am having a problem with the WSDL generator in .NET. It does not account for complex types in one particular method.

Reply from web service

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://www.x.com/2.6.0">
<SOAP-ENV:Body>
 <ns1:Export.GetData xmlns:ns1="http://www.x.com/">
  <return xsi:type="tns:data_warehouse_report">
   <start_row xsi:type="xsd:int">1</start_row>
   <end_row xsi:type="xsd:int">2</end_row>
   <finished xsi:type="xsd:boolean">true</finished>
   <rows xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="tns:data_warehouse_report_row[2]">
    <item xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[3]">
     <item xsi:type="xsd:string">March 12, 2010</item>
     <item xsi:type="xsd:string">recipient3</item>
     <item xsi:type="xsd:string">sample product1</item>
    </item>
    <item xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[0]"></item>
   </rows>
  </return>
 </ns1:Export.GetData>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Pay attention to the lines:

<rows xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="tns:data_warehouse_report_row[2]">
<item xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[3]">

WSDL:

<xsd:complexType name="data_warehouse_report">
  <xsd:all>
    <xsd:element name="start_row" type="xsd:int"/>
    <xsd:element name="end_row" type="xsd:int"/>
    <xsd:element name="finished" type="xsd:boolean"/>
    <xsd:element name="rows" type="tns:data_warehouse_report_row_list"/>
  </xsd:all>
</xsd:complexType>

It is odd that the data_warehouse_report type indicates strings like "data_warehouse_report_list" that are not even used in the response.

My big question is, according to the answer of the web service, how would you create a proxy object data_warehouse_report_row?

I translated it into:

[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.SoapTypeAttribute(Namespace = "http://www.x.com/")]
public partial class data_warehouse_report_row
{
    private string[] itemField;

    public string[] item
    {
        get
        {
            return this.itemField;
        }
        set
        {
            this.itemField = value;
        }
    }
}

But he still complains about the wrong data type during deserialization.

An exception:

InvalidCastException: "Object cannot be stored in an array of this type."

.NET ( System.Xml.Serialization), , , ... , .

?

+3

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


All Articles