我以下列方式调用SOAP服务
BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
EndpointAddress address = new EndpointAddress(System.Configuration.ConfigurationManager.AppSettings.Get("ServiceUri"));
ChannelFactory<IServiceInterface> factory = new ChannelFactory<IServiceInterface>(binding, address);
ISecPay3DSecure channel = factory.CreateChannel();
string rawResponse = channel.MethodName(params);
我使用WSDL.exe生成IServiceInterface
:
wsdl /si https://serviceUri
然后,我使用[ServiceContract]
和[OperationContract]
属性标记了生成的界面。
当我调用channel.MethodName(..);
方法时,它似乎工作正常,但它应该返回的字符串始终是null
,我已经启动了fiddler并且可以看到实际上服务正在响应似乎问题在于渠道根本没有正确处理响应,因此:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: text/xml;charset=utf-8
Date: Thu, 11 Sep 2014 08:48:02 GMT
Transfer-Encoding: chunked
Connection: Keep-Alive
529
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body><ns1:ServiceRequestResponse soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://tempuri.org/">
<ServiceRequestReturn xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">/">?valid=true&test_status=true&tra....
大概是我在频道配置中遗漏了什么?
任何指针都会感激地收到
我还尝试添加ClientMessageInspecor
以查看实际发生的情况,并再次查看
System.ServiceModel.Channels.Message reply
确实有数据。但是一旦它被返回给调用者,它就被设置为null ..
感谢
答案 0 :(得分:0)
似乎是因为我省略了[return: System.Xml.Serialization.SoapElementAttribute("NameOfSoapElement")]
接口方法的属性