title: WCF Service Accepting GZip Messages
body: <p>I am probably missing the obvious, but how can I make it so that one method, PutMessage, on my WCF service can accept both GZip'd and normal requests? Right now I'm seeing this error from my service:</p>
  
  <pre><code>Cannot process the message because the content type 'application/gzip' was not the expected type 'text/xml; charset=utf-8'.
  </code></pre>
  
  <p>I've tried adding a custom binding with binaryMessageCoding/compressionFormat="GZip" and httpTransport. Does this need multiple bindings and multiple endpoints configured? Or multiple bindings and one endpoint? One endpoint and one binding? </p>
  
  <p>I can't change the sending code since it's a third-party that I don't have access to.</p>
  
  <p>Here is my Web.config so far:</p>
  
  <pre><code>  &lt;system.serviceModel&gt;
      &lt;behaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior name="UserNameAuthenticationBehaviour"&gt;
            &lt;serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
            &lt;serviceCredentials&gt;
              &lt;userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="API.Star.XXXUsernamePasswordValidator, API" /&gt;
            &lt;/serviceCredentials&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;bindings&gt;
        &lt;basicHttpBinding&gt;
          &lt;binding name="API.Star.starTransport"&gt;
            &lt;security mode="TransportWithMessageCredential"&gt;
              &lt;transport clientCredentialType="Basic" /&gt;
              &lt;message clientCredentialType="UserName" /&gt;
            &lt;/security&gt;
          &lt;/binding&gt;
        &lt;/basicHttpBinding&gt;
        &lt;customBinding&gt;
          &lt;binding name="API.Star.starTransportGzip"&gt;
            &lt;binaryMessageEncoding compressionFormat="GZip" /&gt;
            &lt;httpTransport /&gt;
          &lt;/binding&gt;
        &lt;/customBinding&gt;
      &lt;/bindings&gt;
      &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /&gt;
      &lt;services&gt;
        &lt;service name="API.Star.StarWebService" behaviorConfiguration="UserNameAuthenticationBehaviour"&gt;
          &lt;endpoint name="StarWebServiceEndpoint" address="" binding="basicHttpBinding" bindingConfiguration="API.Star.starTransport" contract="API.Star.operations" bindingNamespace="http://www.starstandards.org/webservices/2005/10/transport" /&gt;
          &lt;endpoint name="StarWebServiceEndpointGzip" address="" binding="customBinding" bindingConfiguration="API.Star.starTransportGzip" contract="API.Star.operations" bindingNamespace="http://www.starstandards.org/webservices/2005/10/transport" /&gt;
          &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt;
        &lt;/service&gt;
      &lt;/services&gt;
    &lt;/system.serviceModel&gt;
  </code></pre>