Error consuming webservice, content type "application/xop+xml" does not match expected type "text/xml"

For anyone suffering from the same problem; I've found a solution for consuming the web service as a Service Reference (WCF). The BasicHttpBinding.MessageEncoding property needs setting to "Mtom".

Here's a snippet of the required config setting:

<configuration>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding messageEncoding="Mtom">          
        </binding>
      </basicHttpBinding>
    </bindings>
  </system.serviceModel>
</configuration>

Edit: If you are having the same issue with a custom binding please refer to the answer from @robmzd.

I still haven't found a solution for consuming it as an old style Web Reference yet.


After having struggled with this for a few days, I found a remarkably simple solution for this problem:

  1. Activate the Configuration Editor by selecting Tools->WCF Service Configuration Editor from the main menu in VS2010;
  2. Close it again;
  3. Right-click on the App.Config file to find a new menu item "Edit WCF Configuration";
  4. Click on the binding;
  5. Change the MessageEncoding to Mtom;
  6. Save.

I hope this will help someone.


I had the same issue but with <customBinding>. To fix it you can configure Mtom Message Encoding using a separate <mtomMessageEncoding> configuration node under the binding.

<configuration>
  <system.serviceModel>
    <bindings>
      <customBinding>
        <binding name="MyServiceBinding">
          <mtomMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16" messageVersion="Soap12" writeEncoding="utf-8">
            <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
          </mtomMessageEncoding>
        </binding>
      </customBinding>
    </bindings>
  </system.serviceModel>
</configuration>