views:

721

answers:

1

I have a problem with consuming a third-party web service in .NET C#. It runs on Apache (NuSoap). Everything works normally up to deserialization (probably...). When I call the SoapHttpClientProtocol.Invoke() function, I always get an object array with one null object. Bad is that this web service doesn't provide a WSDL document. :-(

Can anybody help me, please? I think, that the deserialization process doesn't run.

Here is soap response:

<?xml version="1.0" encoding="ISO-8859-1"?>
<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/"&gt;
  <SOAP-ENV:Body>
    <ns1:EncodingTestResponse xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/"&gt;

      <item xmlns:ns4071="http://xml.apache.org/xml-soap" xsi:type="ns4071:Map">
        <item>
          <key xsi:type="xsd:string">ascii</key>
          <value xsi:type="xsd:string">ertzyuuioasdcnERSTZYUIOADCN</value>
        </item>
        <item>
          <key xsi:type="xsd:string">latin2</key>
          <value xsi:type="xsd:string">xy</value>
        </item>
        <item>
          <key xsi:type="xsd:string">w1250</key>
          <value xsi:type="xsd:string">pq</value>
        </item>
      </item>

    </ns1:EncodingTestResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Calling method:

[SoapTrace]
[SoapDocumentMethod("EncodingTest",ParameterStyle=SoapParameterStyle.Wrapped)]
public item EncodingTest()
{
    var obj = this.Invoke("EncodingTest", new object[] {});
    return null;
}

and the object, which I was trying to deserialize:

[Serializable] 
[XmlType(Namespace = "http://xml.apache.org/xml-soap", TypeName="item")]
public class item
{
 [XmlArray("item", Form = XmlSchemaForm.Unqualified)]
 public item[] items { get; set; }

 [XmlElement(Form=XmlSchemaForm.Unqualified)]
 public string key { get; set; }

 [XmlElement(Form = XmlSchemaForm.Unqualified)]
 public string value { get; set; }
}
+2  A: 

I solve this, but it wasn't easy. At least i learned controling xml deserialization.. :)

[SoapDocumentMethod(ResponseElementName = "EncodingTestResponse", ResponseNamespace = "http://schemas.xmlsoap.org/soap/envelope/")]
[return: XmlArray("item", Namespace = "", IsNullable = false)]
[SoapTrace]
public item[] EncodingTest()
{
    object[] result = this.Invoke("EncodingTest", new object[] { });
    return (item[])result[0];
}


[SoapType(TypeName = "Map", Namespace = "http://xml.apache.org/xml-soap")]
    public class item
    {
     [XmlElement(Form = XmlSchemaForm.Unqualified)]
     public string key { get; set; }

     [XmlElement(Form = XmlSchemaForm.Unqualified)]
     public string value { get; set; }

     public item[] items { get; set; }
    }
Jan Remunda