title: Trouble using MTOM with WCF
body: <p>In my .NET application I have to consume a WS written in java that uses MTOM to transmit attachements.</p>
  
  <p>I have tried ALL examples and suggestions found on internet with no success.</p>
  
  <p>The response message (captured with Fiddler) from the WS is</p>
  
  <pre><code>HTTP/1.1 200 OK
  X-Backside-Transport: OK OK
  Connection: Keep-Alive
  Date: Wed, 03 Feb 2016 18:24:29 GMT
  Content-Type: multipart/related; boundary="MIMEBoundaryurn_uuid_BA16316AD1D3F515FC1454523870165"; start-info="text/xml"; type="text/xml"; start="&lt;0.urn:uuid:BA16316AD1D3F515FC1454523870166@apache.org&gt;"
  Content-Language: it-IT
  X-Client-IP: 192.168.15.175
  X-Global-Transaction-ID: 136856193
  Content-Length: 1699001
  
  
  
  --MIMEBoundaryurn_uuid_BA16316AD1D3F515FC1454523870165
  Content-Type: text/xml; charset=UTF-8
  Content-Transfer-Encoding: binary
  Content-ID: &lt;0.urn:uuid:BA16316AD1D3F515FC1454523870166@apache.org&gt;
  
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;&lt;soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing"&gt;&lt;wsa:Action&gt;http://MyServer/WS/ReadAttachement&lt;/wsa:Action&gt;&lt;wsa:RelatesTo&gt;da543ac1-f44a-4e9b-a319-0712790a8c78&lt;/wsa:RelatesTo&gt;&lt;/soapenv:Header&gt;&lt;soapenv:Body&gt;&lt;ns2:ReadAttachement xmlns:ns2="http://MyServer/WS/"&gt;&lt;binary&gt;&lt;idDoc&gt;204511&lt;/idDoc&gt;&lt;idRequest&gt;NNNNN&lt;/idRequest&gt;&lt;AccessCode&gt;XXXXX&lt;/AccessCode&gt;&lt;file&gt;&lt;xop:Include href="cid:urn:uuid:BA16316AD1D3F515FC1454523870167@apache.org" xmlns:xop="http://www.w3.org/2004/08/xop/include"/&gt;&lt;/file&gt;&lt;/binary&gt;&lt;message&gt;&lt;code&gt;1&lt;/code&gt;&lt;description&gt;Request OK&lt;/description&gt;&lt;/message&gt;&lt;/ns2:ReadAttachement&gt;&lt;/soapenv:Body&gt;&lt;/soapenv:Envelope&gt;
  --MIMEBoundaryurn_uuid_BA16316AD1D3F515FC1454523870165
  Content-Type: application/octet-stream
  Content-Transfer-Encoding: binary
  Content-ID: &lt;urn:uuid:BA16316AD1D3F515FC1454523870167@apache.org&gt;
  
  ... binary content
  
  --MIMEBoundaryurn_uuid_BA16316AD1D3F515FC1454523870165--
  </code></pre>
  
  <p>and WCF says "Error creating MTOM reader", "MTOM messages must be of type 'application/xop+xml'".</p>
  
  <p>In my Web.config I have the following configuration</p>
  
  <pre><code>&lt;system.serviceModel&gt;
    &lt;bindings&gt;
      &lt;basicHttpBinding&gt;
        &lt;binding name="WSBinding" messageEncoding="Mtom" maxReceivedMessageSize="100000000" &gt;
          &lt;security mode="Transport"&gt;
            &lt;transport clientCredentialType="None" proxyCredentialType="None" realm="" /&gt;
            &lt;message clientCredentialType="Certificate" algorithmSuite="Default" /&gt;
          &lt;/security&gt;
        &lt;/binding&gt;
      &lt;/basicHttpBinding&gt;
    &lt;/bindings&gt;
    &lt;client&gt;
      &lt;endpoint address="http://192.168.40.149:80/WSJava/WS"
        binding="basicHttpBinding" bindingConfiguration="WSBinding"
        contract="WSGesAl.WS" name="WSContract" /&gt;
    &lt;/client&gt;
  &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>Thanks</p>