2
我在使用.NET C#中的第三方Web服務時遇到問題。它運行在Apache(NuSoap)上。一切正常工作到反序列化(可能...)。當我調用SoapHttpClientProtocol.Invoke()
函數時,我總是得到一個帶有一個空對象的對象數組。不好的是,這個Web服務不提供WSDL文檔。 ?:-(C#中的PHP Web服務:Invoke()函數返回null
任何人可以幫助我,請我認爲,反序列化過程中不運行
這裏是SOAP響應:
<?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/">
<SOAP-ENV:Body>
<ns1:EncodingTestResponse xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/">
<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>
調用方法:
[SoapTrace]
[SoapDocumentMethod("EncodingTest",ParameterStyle=SoapParameterStyle.Wrapped)]
public item EncodingTest()
{
var obj = this.Invoke("EncodingTest", new object[] {});
return null;
}
和我試圖反序列化的對象:
[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; }
}
〜我想知道你是否能幫助我,我想我有類似的問題。你真的只是在底部答案中留下的代碼來解決這個問題嗎? – jcolebrand 2010-05-26 00:31:43