title: WCF , The remote server returned an error: (400) Bad Request
body: <p>I am getting this exception when trying to access a wcf web service.</p>
  
  <pre><code>[WebException: The remote server returned an error: (400) Bad Request.]
    System.Net.HttpWebRequest.GetResponse() +5314029
    System.ServiceModel.Channels.HttpChannelRequest.WaitForReply(TimeSpan timeout) +54
  </code></pre>
  
  <p><strong>Server Binding Information</strong></p>
  
  <pre><code>&lt;system.serviceModel&gt;
     &lt;bindings&gt;
        &lt;basicHttpBinding&gt;
           &lt;binding name="wcfSmartConnect" closeTimeout="10:01:00" 
                    maxBufferSize="104857600" maxBufferPoolSize="104857600" 
                    maxReceivedMessageSize="104857600" openTimeout="10:01:00"
                    receiveTimeout="10:10:00" sendTimeout="10:01:00"
                    messageEncoding="Mtom" transferMode="StreamedRequest"&gt;
              &lt;readerQuotas maxDepth="104857600" maxStringContentLength="104857600"
                            maxArrayLength="104857600" maxBytesPerRead="104857600" 
                            maxNameTableCharCount="104857600" /&gt;
           &lt;/binding&gt;
        &lt;/basicHttpBinding&gt;
     &lt;/bindings&gt;
     &lt;services&gt;
        &lt;service name="WcfSmartConnect.Service1"
                 behaviorConfiguration="WcfSmartConnect.Service1Behavior"&gt;
           &lt;endpoint 
                 address="" 
                 binding="basicHttpBinding" 
                 bindingConfiguration="wcfSmartConnect"
                 contract="WcfSmartConnect.IService1"&gt;
              &lt;identity&gt;
                 &lt;dns value="localhost" /&gt;
              &lt;/identity&gt;
           &lt;/endpoint&gt;
           &lt;endpoint 
                 address="mex" 
                 binding="mexHttpBinding" contract="IMetadataExchange" /&gt;
        &lt;/service&gt;
    &lt;/services&gt;
    &lt;behaviors&gt;
        &lt;serviceBehaviors&gt;
             &lt;behavior name="WcfSmartConnect.Service1Behavior"&gt;
              &lt;serviceMetadata httpGetEnabled="true"/&gt;
                  &lt;serviceDebug includeExceptionDetailInFaults="false"/&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
     &lt;/behaviors&gt;
  &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p><strong>Client Binding Information</strong></p>
  
  <pre><code>&lt;system.serviceModel&gt;
     &lt;bindings&gt;
        &lt;basicHttpBinding&gt;
           &lt;binding name="wcfSmartConnect" closeTimeout="10:01:00" 
                    maxBufferSize="104857600" maxBufferPoolSize="104857600" 
                    maxReceivedMessageSize="104857600" openTimeout="10:01:00" 
                    receiveTimeout="10:10:00" sendTimeout="10:01:00" 
                    messageEncoding="Mtom" transferMode="StreamedRequest"&gt;
               &lt;readerQuotas maxDepth="104857600" maxStringContentLength="104857600"
                             maxArrayLength="104857600" maxBytesPerRead="104857600" 
                             maxNameTableCharCount="104857600" /&gt;
           &lt;/binding&gt;
        &lt;/basicHttpBinding&gt;
        &lt;wsHttpBinding&gt;
            &lt;binding name="WSHttpBinding_IService11" closeTimeout="01:00:00"
                     openTimeout="01:00:00" receiveTimeout="01:00:00" 
                     sendTimeout="01:00:00" bypassProxyOnLocal="false" 
                     transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                     maxBufferPoolSize="1048576000" maxReceivedMessageSize="1048576000"
                     messageEncoding="Text" textEncoding="utf-8" 
                     useDefaultWebProxy="true" allowCookies="false"&gt;
                 &lt;readerQuotas maxDepth="104857600" maxStringContentLength="104857600" 
                               maxArrayLength="104857600" maxBytesPerRead="1048576000" 
                               maxNameTableCharCount="104857600" /&gt;
                 &lt;reliableSession ordered="true" inactivityTimeout="00:10:00"
                                  enabled="false" /&gt;
                 &lt;security mode="TransportWithMessageCredential"&gt;
                     &lt;transport clientCredentialType="Windows" 
                                proxyCredentialType="None" realm="" /&gt;
                     &lt;message clientCredentialType="Windows" 
                              negotiateServiceCredential="true" algorithmSuite="Default" 
                              establishSecurityContext="true" /&gt;
                 &lt;/security&gt;
              &lt;/binding&gt;
          &lt;/wsHttpBinding&gt;
     &lt;/bindings&gt;
     &lt;client&gt;
         &lt;endpoint name="WSHttpBinding_IService11"
             address="http://abc.com/API/serv.svc"
             binding="wsHttpBinding" 
             bindingConfiguration="WSHttpBinding_IService11"
             contract="SmartConnectRepublic.IService1" &gt;
             &lt;identity&gt;
                 &lt;dns value="localhost" /&gt;
             &lt;/identity&gt;
         &lt;/endpoint&gt;
         &lt;endpoint name="BasicHttpBinding_IService1" 
             address="http://localhost:4649/Service1.svc" 
             binding="basicHttpBinding"
             bindingConfiguration="wcfSmartConnect" 
             contract="SmartConnect.IService1" /&gt;
     &lt;/client&gt;
  &lt;/system.serviceModel&gt;
  </code></pre>