Search code examples
xmlwcfsoapws-addressing

In sending a soap message "manually" I get AddressingNone error with WCF


I'm trying to send through a SOAP message (that I've extracted) to my WCF service without using the WCF client infrastructure. Without using my production messages (and code), I've been able to setup a dummy version of the same problem (thanks to the WF_WCF_Samples).

So the contract looks like this:

[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);
}

Looking at the SOAP message that the actual WCF client sends I get this in the WCF Tracing:

<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>

And that is from the working call. However, if I try to do it I get the following exception that gets logged in the WCF tracing:

Addressing Version 'AddressingNone (http://schemas.microsoft.com/ws/2005/05/addressing/none)' does not support adding WS-Addressing headers.

I've tried something like SoapUI and even Httpie to send an XML file:

Httpie sending Soap message - failure

So I get back an HTTP error 400 - Bad request.

I am currently using the basicHttp(s)Binding WCF binding.

I've tried messing with the bindings but nothing is working. Any thoughts?


Solution

  • I was stunned that WCF actually added the following header in the SOAP message when I looked at the WCF tracing (on the service side, not the client side):

    <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>
    

    When I took it out, my request went through without a problem.

    Httpie sending Soap message - success

    In setting up something like Wireshark I managed to see that the actual message didn't contain this header. Somewhere WCF was adding that in the SOAP header during tracing. But sending that through was invalid. The HTTP Soap Action header is sufficient.