The remote server returned an error: (400) Bad Request
<p>I am getting the following errors:</p>

<blockquote>
  <p>"The remote server returned an error:
  (400) Bad Request"</p>
  
  <p>"Requested time out"</p>
</blockquote>

<p>sometimes when connecting to a host using a web service. If the XML returned is 5 kb then it is working fine, but if the size is 450kb or above it is displaying the error.</p>

<p>Below is my code as well as the config file that resides at the client system. We don't have access to the settings of the server.</p>

<pre><code> Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim fileName As String = Server.MapPath("capitaljobs2.xml")

        Dim client = New CapitalJobsService.DataServiceClient("WSHttpBinding_IDataService", "http://xyz/webservice.svc")


        Dim userAccount = New UserAccount()

        'replace here 
        Dim jobAdList = client.GetProviderJobs(userAccount)

        '## Needed only to create XML files - do not ucomment - will overwrite files 
        'if (jobAdList != null) 
        ' SerialiseJobAds(fileName, jobAdList); 

        '## Read new ads from Xml file 
        Dim capitalJobsList = DeserialiseJobdAds(fileName)
        UpdateProviderJobsFromXml(client, userAccount, capitalJobsList)              
        client.Close()
    End Sub

 Private Shared Function DeserialiseJobdAds(ByVal fileName As String) As CapitalJobsService.CapitalJobsList
        Dim capitalJobsList As CapitalJobsService.CapitalJobsList
        ' Deserialize the data and read it from the instance 
        If File.Exists(fileName) Then
            Dim fs = New FileStream(fileName, FileMode.Open)
            Dim reader = XmlDictionaryReader.CreateTextReader(fs, New XmlDictionaryReaderQuotas())
            Dim ser2 = New DataContractSerializer(GetType(CapitalJobsList))
            capitalJobsList = DirectCast(ser2.ReadObject(reader, True), CapitalJobsList)
            reader.Close()
            fs.Close()
            Return capitalJobsList
        End If
        Return Nothing
    End Function
</code></pre>

<p>And the config file</p>

<pre><code> &lt;system.web&gt;
 &lt;httpRuntime maxRequestLength="524288" /&gt;
  &lt;/system.web&gt;
    &lt;system.serviceModel&gt;
     &lt;bindings&gt;
      &lt;wsHttpBinding&gt;
        &lt;binding name="WSHttpBinding_IDataService" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"&gt;
          &lt;readerQuotas maxDepth="2000000" maxStringContentLength="2000000" maxArrayLength="2000000" maxBytesPerRead="2000000" maxNameTableCharCount="2000000" /&gt;
          &lt;reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" /&gt;
        &lt;security mode="None"&gt;
         &lt;transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/&gt;
         &lt;message clientCredentialType="Windows" negotiateServiceCredential="true" establishSecurityContext="true"/&gt;
        &lt;/security&gt;
       &lt;/binding&gt;
      &lt;/wsHttpBinding&gt;
     &lt;/bindings&gt;
     &lt;client&gt;
      &lt;endpoint address="http://xyz/DataService.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IDataService" contract="CapitalJobsService.IDataService" name="WSHttpBinding_IDataService"&gt;
           &lt;identity&gt;
        &lt;dns value="localhost"/&gt;
       &lt;/identity&gt;
      &lt;/endpoint&gt;
     &lt;/client&gt;
    &lt;/system.serviceModel&gt;
</code></pre>

<p>I am using "Fiddler" to track the activities it is reading and terminating file like</p>

<blockquote>
  <p><strong>* FIDDLER: RawDisplay truncated at 16384 characters. Right-click to
  disable truncation. *</strong></p>
</blockquote>

<p>But in config the number 16348 is not mentioned anywhere.</p>

<p>Can you figure out if the error is on client or server side? The settings above are on the client side.</p>

<p>Thanks in advance.</p>
