我在.net中使用“添加服务引用”来使用php soap web servcie。但是,它始终返回null。我附上了c#代码和下面的fiddler捕获的软件包。
我创建了一个IClientMessageInspector实现,它将响应写入AfterReceiveReply方法的日志文件中,非常好。任何人都可以知道内部有什么问题以及如何解决它?谢谢!
此致 罗恩
调用Web服务的C#代码:
var service = new ServiceReference1.APIServicePortTypeClient();
var reponse = service.manageSubscription(@"<?xml version='1.0' standalone='yes'?>
<customer name=""TEST group"" version=""1.0.0"">
<instance name=""TEST"" fullname=""Just for test"" source=""Test"">
<lists>
<list name=""api_send_mail"" type=""subscribe"" />
</lists>
<data>
<email>ron@abcd.com</email>
</data>
</instance>
</customer>");
Assert.IsNotNull(reponse); // exception happens here...
以下是fiddler抓住的包裹:
请求:
POST http://someurl.php HTTP/1.1
Content-Type: text/xml; charset=utf-8
SOAPAction: "urn:xmethods-delayed-quotes#manageSubscription"
Host: inxau.de
Content-Length: 905
Expect: 100-continue
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Header><APIToken xmlns="http://schemas.xmlsoap.org/ws/2002/07/utility">12345678</APIToken></s:Header><s:Body s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><q1:manageSubscription xmlns:q1="urn:xmethods-delayed-quotes"><xml xsi:type="xsd:string"><?xml version='1.0' standalone='yes'?>
<customer name="Test group" version="1.0.0">
<instance name="TEST" fullname="Just for test" source="Test">
<lists>
<list name="api_send_mail" type="subscribe" />
</lists>
<data>
<email>ron@abcd.com</email>
</data>
</instance>
</customer></xml></q1:manageSubscription></s:Body></s:Envelope>
响应:
HTTP/1.1 200 OK
Date: Thu, 01 Mar 2012 00:03:40 GMT
Server: Apache/2.2.3 (CentOS)
X-Powered-By: PHP/5.3.8
Content-Length: 761
MS-Author-Via: DAV
Connection: close
Content-Type: text/xml; charset=utf-8
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="inxau.de" 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:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:manageSubscriptionResponse><return xsi:type="xsd:string"><?xml version="1.0" encoding="UTF-8"?>
<result>
<instance name="TEST group" value="1" process_id="1001">
<data>
<email>ron@abcd.com</email>
</data>
</instance>
</result>