-1

I am sending a very long string to service which at present is 318771 characters long. I am getting an error The remote server returned an unexpected response: (400) Bad Request.

** CLIENT APP.CONFIG **

<bindings>
    <basicHttpBinding>
        <binding name="BasicHttpBinding_INBFC" closeTimeout="00:01:00"
            openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
            allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
            maxBufferSize="20000000" maxBufferPoolSize="20000000" maxReceivedMessageSize="20000000"
            messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
            useDefaultWebProxy="true">
            <readerQuotas maxDepth="32" maxStringContentLength="200000000"
                maxArrayLength="200000000" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
            <security mode="None">
                <transport clientCredentialType="None" proxyCredentialType="None"
                    realm="" />
                <message clientCredentialType="UserName" algorithmSuite="Default" />
            </security>
        </binding>
    </basicHttpBinding>
</bindings>

** SERVICE APP.CONFIG **

<system.web>
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.0"/>
    <pages>
      <namespaces>
        <add namespace="System.Runtime.Serialization"/>
        <add namespace="System.ServiceModel"/>
        <add namespace="System.ServiceModel.Web"/>
      </namespaces>
    </pages>
  </system.web>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>



          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- 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 -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
Seymour
  • 7,043
  • 12
  • 44
  • 51
SamuraiJack
  • 5,131
  • 15
  • 89
  • 195
  • possible duplicate of [The remote server returned an unexpected response: (400) Bad Request](http://stackoverflow.com/questions/1651143/the-remote-server-returned-an-unexpected-response-400-bad-request) – CodeCaster Mar 31 '14 at 12:20

2 Answers2

0

A case of malformed request from W3

Check if the service is able to recieve the request using SOAP UI, also check if the datatypes between server and client calls match.

LakshmiNarayanan
  • 1,158
  • 9
  • 12
0

I suspect that your issue involves the WCF binding configuration. In particular, the maxReceivedMessageSize value and/or the readerQuota settings. If you provide your client/server bindings (or the entire relevant sections of the configuration file, we could provide better guidance.)

Note: you may want to enable WCF tracing, if you have not already, to help determine the cause of the issue. Reference: http://msdn.microsoft.com/en-us/library/ms733025(v=vs.110).aspx

Seymour
  • 7,043
  • 12
  • 44
  • 51
  • Your service configuration does not show the service definition or the service bindings, so it is hard to tell if the maxReceivedMessageSize value and/or the readerQuota settings on the service match the client. – Seymour Mar 31 '14 at 13:05