title: WCF service exposing multiple endpoints giving error 400/415
body: <p>We have a WCF SOAP service hostied in IIS, that is used to upload binary data. To allow larger payloads (avoiding base64-encoded binary data) we want to add an endpoint that accepts MTOM messages, while retaining the current SOAP endpoint for legacy clients and backwards compatibility. Thus the desired end result is the following:</p>
  
  <blockquote>
    <p><a href="http://www.myorg.com/Service.svc" rel="nofollow noreferrer">http://www.myorg.com/Service.svc</a> gives the SOAP endpoint (currently exists and works)
    <a href="http://www.myorg.com/Service.svc/mtom" rel="nofollow noreferrer">http://www.myorg.com/Service.svc/mtom</a> gives the SOAP w/MTOM endpoint (new, doesn't work)</p>
  </blockquote>
  
  <p>I thought this would be as easy as adding an additional <code>&lt;endpoint&gt;</code> element with its <code>bindingConfiguration</code> set to point to a new <code>&lt;binding messageEncoding="Mtom"&gt;</code> element, but this doesn't work: when attempting to GET <code>http://www.myorg.com/Service.svc/mtom</code> the server always returns error 400 with an empty response body. When attempting to POST to the same endpoint (via the WCF Test Client) an error 415 is returned: </p>
  
  <blockquote>
    <p>Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'."</p>
  </blockquote>
  
  <p>My config:</p>
  
  <pre><code>&lt;behaviors&gt;
    &lt;serviceBehaviors&gt;
      &lt;behavior name="Service"&gt;
        &lt;serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /&gt;
        &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
        &lt;useRequestHeadersForMetadataAddress&gt;
          &lt;defaultPorts&gt;
            &lt;add scheme="http" port="80" /&gt;
            &lt;add scheme="https" port="443" /&gt;
          &lt;/defaultPorts&gt;
        &lt;/useRequestHeadersForMetadataAddress&gt;
      &lt;/behavior&gt;
    &lt;/serviceBehaviors&gt;
  &lt;/behaviors&gt;
  &lt;bindings&gt;
    &lt;basicHttpBinding&gt;
      &lt;binding name="ServiceMTOM" messageEncoding="Mtom" maxReceivedMessageSize="2147483647"&gt;
        &lt;security mode="Transport"&gt;
          &lt;transport clientCredentialType="None" /&gt;
        &lt;/security&gt;
        &lt;readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="16384" /&gt;
      &lt;/binding&gt;
      &lt;binding name="Service" maxReceivedMessageSize="2147483647"&gt;
        &lt;security mode="Transport"&gt;
          &lt;transport clientCredentialType="None" /&gt;
        &lt;/security&gt;
        &lt;readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="16384" /&gt;
      &lt;/binding&gt;
    &lt;/basicHttpBinding&gt;
  &lt;/bindings&gt;
  &lt;services&gt;
    &lt;service name="Service" behaviorConfiguration="Service"&gt;
      &lt;endpoint address="" binding="basicHttpBinding" contract="MyNamespace.Service" bindingConfiguration="Service" /&gt;
      &lt;endpoint address="mtom" binding="basicHttpBinding" contract="MyNamespace.Service" bindingConfiguration="ServiceMTOM" /&gt;
      &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt;
    &lt;/service&gt;
  &lt;/services&gt;
  </code></pre>
  
  <p>It's been a long time since I've had to work with WCF - what am I missing?</p>