【问题标题】:x-www-form-urlencoded response ignored by WCF Service callX-www-form-urlencoded 响应被 WCF 服务调用忽略
【发布时间】:2014-09-11 08:51:29
【问题描述】:

我正在通过以下方式调用 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&amp;test_status=true&amp;tra....

大概是我在频道配置中遗漏了什么?

任何指点将不胜感激

我还尝试添加ClientMessageInspecor 以查看实际情况并再次 System.ServiceModel.Channels.Message reply 确实有数据。但是一旦返回给调用者,它就被设置为 null..

谢谢

【问题讨论】:

    标签: c# .net wcf channelfactory


    【解决方案1】:

    似乎是因为我省略了[return: System.Xml.Serialization.SoapElementAttribute("NameOfSoapElement")] 来自接口方法的属性

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-13
      • 1970-01-01
      • 2019-01-03
      • 1970-01-01
      • 1970-01-01
      • 2011-04-29
      • 1970-01-01
      相关资源
      最近更新 更多