title: WCF - The remote server returned an unexpected response: (400) Bad Request
body: <p>I am getting this error while passing byte[] to WCF. Can someone plz solve this error??</p>
  
  <p>Configuration at Service(web.config)</p>
  
  <pre><code>&lt;configuration&gt;
      &lt;system.web&gt;
          &lt;compilation debug="true" targetFramework="4.0"/&gt;
      &lt;/system.web&gt;
      &lt;system.serviceModel&gt;
          &lt;bindings&gt;
     &lt;basicHttpBinding&gt;
      &lt;binding name="NewBinding0" maxBufferSize="2097151" maxBufferPoolSize="2097151"
       maxReceivedMessageSize="2097151" messageEncoding="Mtom"
       transferMode="Streamed"&gt;
       &lt;readerQuotas maxDepth="2097151" maxStringContentLength="2097151"
        maxArrayLength="2097151" maxBytesPerRead="2097151" maxNameTableCharCount="2097151" /&gt;
      &lt;/binding&gt;
     &lt;/basicHttpBinding&gt;
     &lt;mexHttpBinding&gt;
      &lt;binding name="higherMessageSize_MEX" /&gt;
     &lt;/mexHttpBinding&gt;
    &lt;/bindings&gt;
    &lt;client&gt;
     &lt;endpoint binding="basicHttpBinding" bindingConfiguration="NewBinding0"
      contract="LService.IService"&gt;
      &lt;identity&gt;
       &lt;dns value="localhost" /&gt;
      &lt;/identity&gt;
     &lt;/endpoint&gt;
     &lt;endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="higherMessageSize_MEX"
      contract="IMetadataExchange" /&gt;
    &lt;/client&gt;
    &lt;behaviors&gt;
              &lt;serviceBehaviors&gt;
                  &lt;behavior&gt;
                      &lt;!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --&gt;
                      &lt;serviceMetadata httpGetEnabled="true"/&gt;
                      &lt;!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information --&gt;
                      &lt;serviceDebug includeExceptionDetailInFaults="false"/&gt;
                  &lt;/behavior&gt;
              &lt;/serviceBehaviors&gt;
          &lt;/behaviors&gt;
          &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true"/&gt;
      &lt;/system.serviceModel&gt;
      &lt;system.webServer&gt;
          &lt;modules runAllManagedModulesForAllRequests="true"/&gt;
      &lt;/system.webServer&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Configuration at WPF application (app.config)</p>
  
  <pre><code>&lt;configuration&gt;
      &lt;system.serviceModel&gt;
          &lt;bindings&gt;
              &lt;basicHttpBinding&gt;
                  &lt;binding name="BasicHttpBinding_IService" closeTimeout="00:01:00"
                      openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                      allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                      maxBufferSize="2097151" maxBufferPoolSize="2097151" maxReceivedMessageSize="2097151"
                      messageEncoding="Mtom" textEncoding="utf-8" transferMode="Streamed"
                      useDefaultWebProxy="true"&gt;
                      &lt;readerQuotas maxDepth="2097151" maxStringContentLength="2097151"
                          maxArrayLength="2097151" maxBytesPerRead="2097151" maxNameTableCharCount="2097151" /&gt;
                      &lt;security mode="None"&gt;
                          &lt;transport clientCredentialType="None" proxyCredentialType="None"
                              realm="" /&gt;
                          &lt;message clientCredentialType="UserName" algorithmSuite="Default" /&gt;
                      &lt;/security&gt;
                  &lt;/binding&gt;
              &lt;/basicHttpBinding&gt;
          &lt;/bindings&gt;
          &lt;client&gt;
              &lt;endpoint address="http://localhost:5980/LService/Service.svc"
                  binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
                  contract="LService.IService" name="BasicHttpBinding_IService" /&gt;
          &lt;/client&gt;
      &lt;/system.serviceModel&gt;
  &lt;/configuration&gt;
  </code></pre>