C# WCF服务调用忽略了x-www-form-urlencoded响应
我用以下方式调用SOAP服务C# WCF服务调用忽略了x-www-form-urlencoded响应,c#,.net,wcf,channelfactory,C#,.net,Wcf,Channelfactory,我用以下方式调用SOAP服务 BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport); EndpointAddress address = new EndpointAddress(System.Configuration.ConfigurationManager.AppSettings.Get("ServiceUri")); ChannelFactory<IServiceInterfa
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);
然后,我用[ServiceContract]
和[OperationContract]
属性标记生成的接口
当我调用channel.MethodName(..)时
method它似乎工作正常,但它应该返回的字符串总是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....
HTTP/1.1200正常
服务器:ApacheCoote/1.1
内容类型:text/xml;字符集=utf-8
日期:2014年9月11日星期四08:48:02 GMT
传输编码:分块
连接:保持活力
529
/“>?有效=正确和测试状态=正确和传输…”。。。。
我可能在通道配置中遗漏了什么
任何指点都将不胜感激
我还尝试添加了一个ClientMessageInspecor
,以查看实际发生了什么,然后再次添加
System.ServiceModel.Channels.Message reply
中确实包含数据。但一旦返回给调用方,它就被设置为null
谢谢似乎是因为我省略了
[return:System.Xml.Serialization.SoapElementAttribute(“NameOfSoapElement”)]
接口方法中的属性
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....