我有一个第三方SOAP客户端,能够与旧的ASMX old服务进行通信。
问题出在WCF服务上。
我的WCF服务接收来自此客户端的消息时没有问题,但是客户端不喜欢我的WCF响应。
我的测试WCF服务发送以下响应:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<testResponse xmlns="http://www.tempuri.org">
<testResult>randomStringData</testResult>
</testResponse>
</s:Body>
</s:Envelope>但是旧的SOAP客户端需要这样的响应(ASMX服务):
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<testResponse xmlns="http://tempuri.org/">
<testResult>randomStringData</testResult>
</testResponse>
</soap:Body>
</soap:Envelope>我无法控制客户。有没有一种方法可以将我的WCF配置为发送与ASMX服务完全相同的消息?
我的WCF服务正在使用以下绑定:
<customBinding>
<binding name="soap11">
<textMessageEncoding messageVersion="Soap11" writeEncoding="utf-8"></textMessageEncoding>
<httpTransport></httpTransport>
</binding>
</customBinding>发布于 2012-11-25 05:59:11
我设法用自定义消息检查器和BeforeSendReply方法解决了前缀问题。
http://msdn.microsoft.com/en-us/library/system.servicemodel.dispatcher.idispatchmessageinspector.beforesendreply.aspx
附注:另一个很棒的方法是AfterReceiveRequest,用于各种消息调整魔术!
https://stackoverflow.com/questions/13434815
复制相似问题