【问题标题】:In sending a soap message "manually" I get AddressingNone error with WCF在“手动”发送肥皂消息时,我收到 WCF 的 AddressingNone 错误
【发布时间】:2016-09-13 20:24:28
【问题描述】:

我正在尝试通过 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);
}

查看实际 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>

那是来自工作电话。 但是,如果我尝试这样做,则会在 WCF 跟踪中记录以下异常:

寻址版本“AddressingNone (http://schemas.microsoft.com/ws/2005/05/addressing/none)”不支持添加 WS-Addressing 标头。

我尝试过类似 SoapUI 甚至 Httpie 来发送 XML 文件:

所以我得到一个 HTTP 错误 400 - 错误请求。

我目前正在使用 basicHttp(s)Binding WCF 绑定。

我试过弄乱绑定,但没有任何效果。有什么想法吗?

【问题讨论】:

    标签: xml wcf soap ws-addressing


    【解决方案1】:

    当我查看 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>
    

    当我取出它时,我的请求顺利通过。

    在设置 Wireshark 之类的东西时,我设法看到实际消息不包含此标头。在跟踪期间,WCF 在某处将其添加到 SOAP 标头中。但是发送它是无效的。 HTTP Soap Action 标头就足够了。

    【讨论】:

      猜你喜欢
      • 2017-08-20
      • 2012-07-17
      • 1970-01-01
      • 1970-01-01
      • 2016-04-11
      • 1970-01-01
      • 2018-04-12
      • 1970-01-01
      • 2017-11-24
      相关资源
      最近更新 更多