废话不多说 直接贴代码先,具体的WCF代码和配置就不贴了,因为在C#中的调用时杠杠的。
SOAPUI中的内容
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">
<soap:Header/>
<soap:Body>
<tem:DoWork>
<!--Optional:-->
<tem:a>这是一个测试!</tem:a>
</tem:DoWork>
</soap:Body>
</soap:Envelope>
调用SOAPUI返回的结果
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1">http://www.w3.org/2005/08/addressing/soap/fault</a:Action>
</s:Header>
<s:Body>
<s:Fault>
<s:Code>
<s:Value>s:Sender</s:Value>
<s:Subcode>
<s:Value>a:DestinationUnreachable</s:Value>
</s:Subcode>
</s:Code>
<s:Reason>
<s:Text xml:lang="zh-CN">由于 AddressFilter 在 EndpointDispatcher 不匹配,To 为“”的消息无法在接收方处理。请检查发送方和接收方的 EndpointAddresses 是否一致。</s:Text>
</s:Reason>
</s:Fault>
</s:Body>
</s:Envelope>
注意红字地方的错误
具体解决方案如下:添加(蓝色字体)如下内容
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">
<soap:Header>
<a:To s:mustUnderstand="1" xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">http://localhost:8025/CompetenceOperation</a:To>
</soap:Header
>
<soap:Body>
<tem:DoWork>
<!--Optional:-->
<tem:a>这是一个测试!</tem:a>
</tem:DoWork>
</soap:Body>
</soap:Envelope>
相关解决方案文章如下:
https://msdn.microsoft.com/en-us/library/bb246105.aspx
http://blogs.msdn.com/b/nabeelp/archive/2008/03/07/obscure-error-addressfilter-mismatch-at-the-endpointdispatcher.aspx
http://blog.csdn.net/jan_s/article/details/37656437