title: Error-The remote server returned an unexpected response: (400) Bad Request.
body: <p>I have a WCF which I get the    </p>
  
  <pre><code>"The remote server returned an unexpected response: (400) Bad Request."
  </code></pre>
  
  <p>error just in calling a specific Method of it.</p>
  
  <p>This is web.Config in server side</p>
  
  <pre><code>&lt;configuration&gt;
  &lt;connectionStrings&gt;
  &lt;remove name="LocalSqlServer"/&gt;
  &lt;add name="CableContext" connectionString="metadata=res://*/CableModel.csdl|res://*/CableModel.ssdl|res://*/CableModel.msl;provider=System.Data.SqlClient;provider connection string=&amp;quot;data source=pgdbserver;initial catalog=CableDB;integrated security=True;multipleactiveresultsets=True;App=EntityFramework&amp;quot;" providerName="System.Data.EntityClient" /&gt;     
   &lt;/connectionStrings&gt;
  
  &lt;system.web&gt;
  &lt;compilation debug="true" targetFramework="4.0" /&gt;
  
  &lt;/system.web&gt;
  &lt;system.serviceModel&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="true"/&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>and this is the app.config in client side</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
     &lt;configuration&gt;
       &lt;appSettings&gt;
         &lt;add key="UserManager" value="http://appserver:8080/SecurityServices/UserManager.asmx" /&gt;
        &lt;add key="ClientSettingsProvider.ServiceUri" value="" /&gt;
       &lt;/appSettings&gt;
      &lt;system.serviceModel&gt;
      &lt;bindings&gt;
        &lt;basicHttpBinding&gt;
            &lt;binding name="BasicHttpBinding_ICableService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="9830400" maxBufferPoolSize="524288" maxReceivedMessageSize="9830400" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"&gt;
        &lt;readerQuotas maxDepth="64" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /&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://appserver:8080/CableDataService/CableService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICableService" contract="CableServiceReference.ICableService" name="BasicHttpBinding_ICableService" /&gt;
      &lt;/client&gt;
     &lt;/system.serviceModel&gt;
     &lt;system.web&gt;
      &lt;membership defaultProvider="ClientAuthenticationMembershipProvider"&gt;
    &lt;providers&gt;
      &lt;add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" /&gt;
    &lt;/providers&gt;
  &lt;/membership&gt;
  &lt;roleManager defaultProvider="ClientRoleProvider" enabled="true"&gt;
    &lt;providers&gt;
      &lt;add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" /&gt;
    &lt;/providers&gt;
    &lt;/roleManager&gt;
    &lt;/system.web&gt;
    &lt;/configuration&gt;
  </code></pre>
  
  <p>and this is the code I am Calling </p>
  
  <pre><code>   public int Export(Cable cableToSave )
      {
          int result = 0;
          using (UnitOfWork unitOfWork = new UnitOfWork())
          {
  
                          if (cableToSave.CableProperty != null &amp;&amp; cableToSave.CableProperty.CableApplication != null &amp;&amp; cableToSave.CableProperty.CableApplication.State == State.Added)
                          {
                              cableToSave.CableProperty.CableApplication.CableProperties = null;
                              unitOfWork.CableApplicationRepository.Insert(cableToSave.CableProperty.CableApplication);
                          }
                          if (cableToSave.CableProperty != null &amp;&amp; cableToSave.CableProperty.State == State.Added)
                          {
                              cableToSave.CableProperty.Cables = null;
                              unitOfWork.CablePropertyRepository.Insert(cableToSave.CableProperty);
                          }
                          if (cableToSave.State == State.Added)
                          {
                              unitOfWork.CableRepository.Insert(cableToSave);
                              result = cableToSave.Id;
                              if (cableToSave.Cores != null)
                              foreach (Core coreToSave in cableToSave.Cores)
                              {
                                  unitOfWork.CoreRepository.Insert(coreToSave);
                              }
                          }                            
  
  
              unitOfWork.Save();
              return result;
          }
      }
  </code></pre>