'WCF client exception: Unrecognized message version

I hit this error today when deploying a WCF client to QA:

System.ServiceModel.CommunicationException: Unrecognized message version.

In Fiddler I noticed that the WCF client sends its request wrapped in a SOAP Envelope (as expected) but that the response from the remote web service is not wrapped in a SOAP Envelope. That is, our local debug web service sends a response like this:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header />
  <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <Response xmlns="urn:example">
      <Success>true</Success>
      ...
    </Response>
  </s:Body>
</s:Envelope>

But the remote web service is just sending this:

<?xml version="1.0" encoding="utf-8"?>
<ns0:Response xmlns:ns0="urn:example">
  <ns0:Success>true</ns0:Success>
  ...
</ns0:Response>

As far as I can tell the WCF client is throwing the exception because there's no SOAP Envelope. So my questions are:

  1. Is my assumption correct or should be I looking elsewhere?
  2. Is there some way to configure the WCF client's bindings to remove the SOAP Envelope expectation?
  3. Should I just tell the remote service implementor to fix their service (which they wrote just for us from a supplied WSDL)?

The WCF client is using basicHttpBindings (and HTTP Basic Authentication over SSL/TLS). I'd considered using IClientMessageInspector.AfterReceiveReply() to rewrite the response but the exception gets thrown before that method is invoked, i.e.: We already have an implementation of it for request/response logging and it's not hitting a breakpoint in there.


More info:

After communicating with the service developer it sounds like they completely ignored the .wsdl and (svcutil generated) IService.cs files we gave them and wrote a POX (Plain-Old XML) service from scratch.

I'm not confident that we can convince them to do it properly, so now I'm looking for tips to convert a properly behaving WCF SOAP client into a POX client.



Solution 1:[1]

This may be caused by that your service uses Soap1.2 while you are using a different version to call it.

Please try "Add Service Reference" - "Advanced..." - "Add Web Reference..." as a compatibility approach.

Solution 2:[2]

I had this issue as well. I know this is an older post, but in my case I modified the app.config file in my C# .NET app that calls this web service. I think it was adding

<security mode="Transport" />

to the basicHttpBinding element that solved it. I also extended the timeouts and maxBufferPoolSize.

Microsoft has documentation that describes this, in case this helps someone else.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Weifeng
Solution 2 Jeremy Caney