Dan*_*dré 2 xml wcf soap ws-addressing
我正在尝试通过 SOAP 消息(我已提取)发送到我的 WCF 服务,而不使用 WCF 客户端基础结构。在不使用我的生产消息(和代码)的情况下,我已经能够设置同一问题的虚拟版本(感谢 WF_WCF_Samples)。
所以合同看起来像这样:
[ServiceContract(Namespace="http://Microsoft.Samples.UsingUsing")]
public interface ICalculator
{
[OperationContract]
double Add(double n1, double n2);
[OperationContract]
double Subtract(double n1, double n2);
[OperationContract]
double Multiply(double n1, double n2);
[OperationContract]
double Divide(double n1, double n2);
}
Run Code Online (Sandbox Code Playgroud)
查看实际 WCF 客户端发送的 SOAP 消息,我在 WCF 跟踪中得到以下信息:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<To s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://localhost:56852/service.svc</To>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://Microsoft.Samples.UsingUsing/ICalculator/Divide</Action>
</s:Header>
<s:Body>
<Divide xmlns="http://Microsoft.Samples.UsingUsing">
<n1>0</n1>
<n2>0</n2>
</Divide>
</s:Body>
</s:Envelope>
Run Code Online (Sandbox Code Playgroud)
这是工作电话中的内容。但是,如果我尝试执行此操作,则会收到记录在 WCF 跟踪中的以下异常:
寻址版本“AddressingNone ( http://schemas.microsoft.com/ws/2005/05/addressing/none )”不支持添加 WS-Addressing 标头。
我尝试过使用 SoapUI 甚至 Httpie 来发送 XML 文件:
所以我收到了 HTTP 错误 400 - 错误请求。
我目前正在使用 basicHttp(s)Binding WCF 绑定。
我尝试过弄乱绑定,但没有任何效果。有什么想法吗?
当我查看 WCF 跟踪(在服务端,而不是客户端)时,令我惊讶的是 WCF 实际上在 SOAP 消息中添加了以下标头:
<To s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://localhost:56852/service.svc</To>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://Microsoft.Samples.UsingUsing/ICalculator/Divide</Action>
Run Code Online (Sandbox Code Playgroud)
当我把它拿出来时,我的请求毫无问题地通过了。
在设置像 Wireshark 这样的东西时,我设法看到实际的消息不包含这个标头。WCF 在跟踪过程中将其添加到 SOAP 标头中。但发送该信息是无效的。HTTP Soap Action 标头就足够了。