title: The content type text/html;charset=UTF-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8)
body: <p>I am getting this error when consuming web service. I had tried many solutions given by experts but didn't worked in my project.</p>
  
  <p><a href="https://stackoverflow.com/questions/15481092/the-content-type-application-xmlcharset-utf-8-of-the-response-message-does-not">The content type application/xml;charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8)</a></p>
  
  <p>Error:</p>
  
  <blockquote>
    <p>The content type text/html;charset=UTF-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly.</p>
  </blockquote>
  
  <p>My web.config file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
      &lt;startup&gt; 
          &lt;supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /&gt;
      &lt;/startup&gt;
      &lt;system.serviceModel&gt;
          &lt;bindings&gt;
              &lt;basicHttpBinding&gt;
                  &lt;binding name="ping_binding"&gt;
                      &lt;security mode="Transport" /&gt;
                  &lt;/binding&gt;
                  &lt;binding name="ping_binding1" /&gt;
              &lt;/basicHttpBinding&gt;
          &lt;/bindings&gt;
          &lt;client&gt;
              &lt;endpoint address="https://xxxx.com/ping/ping" binding="basicHttpBinding"
                  bindingConfiguration="ping_binding" contract="NiprWebService.pingIF"
                  name="ping" /&gt;
          &lt;/client&gt;
      &lt;/system.serviceModel&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>C# code</p>
  
  <pre><code>ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
  
          using (var ws = new NiprWebService.pingIFClient())
          {
              using (new OperationContextScope(ws.InnerChannel))
              {
                  var requestMessage = new HttpRequestMessageProperty();
                  string authInfo = USER + ":" + PASS;
  
                  authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
                  requestMessage.Headers.Add("Authorization", "Basic " + authInfo);
                  requestMessage.Headers.Add("Accept", "text/xml");
                  requestMessage.Headers.Add("ContentType", "text/xml; charset=utf-8");
                  //requestMessage.Headers.Add("Method", "POST");
                  OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] =
                      requestMessage;
              }
  
              var gw = new NiprWebService.gateway();
              var pr = ws.gateway(gw);
              Console.WriteLine(pr.available);
  
          }
  </code></pre>