0

I have a WCF service which works great when small data has to be transferred over the wire. When I increase the data to a bigger size, I get following error:

The remote server returned an unexpected response: (400) Bad Request.

I know that this question has been asked many times be other user. But, I have tried all of those approaches to fix this issue. Nothing is working for me. Can you please have a look at my config contents and let me know if I am missing something. Following is my services' config file.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" />
  </system.web>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <services>
      <service name="RecieveValidationResultHubServiceLibrary.ReceiveValidationResultHubService">
        <endpoint address="" binding="basicHttpBinding" contract="RecieveValidationResultHubServiceLibrary.IReceiveValidationResultHubService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8735/Design_Time_Addresses/RecieveValidationResultHubServiceLibrary/ReceiveValidationResultHubService/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="True" httpsGetEnabled="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>
  </system.serviceModel>
</configuration>

Following is service reference config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
    <add key="MaxParallelThreads" value="300"/>
  </appSettings>
  <system.web>
    <compilation debug="true" />
  </system.web>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IReceiveValidationResultHubService" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="Streamed"/>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:8735/Design_Time_Addresses/RecieveValidationResultHubServiceLibrary/ReceiveValidationResultHubService/"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IReceiveValidationResultHubService"
        contract="ReceiveValidationServiceReference.IReceiveValidationResultHubService"
        name="BasicHttpBinding_IReceiveValidationResultHubService" />
    </client>
    <services>
      <service name="StartValidationClientServiceLibrary.StartValidationClientService">
        <endpoint address="" binding="basicHttpBinding" contract="StartValidationClientServiceLibrary.IStartValidationClientService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8734/Design_Time_Addresses/StartValidationClientServiceLibrary/StartValidationClientService/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="True" httpsGetEnabled="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>
  </system.serviceModel>
</configuration>
K S
  • 301
  • 1
  • 4
  • 16
  • 1
    It would be helpful to know which "fixes" you've tried so we don't end up on the same wild goose chase. – Cᴏʀʏ Jul 14 '14 at 22:35
  • You probably need to enlarge the message size quota as explained [here](http://stackoverflow.com/questions/884235/wcf-how-to-increase-message-size-quota). – venerik Jul 14 '14 at 22:38
  • I have tried: maxBufferPoolSize="2000000" maxReceivedMessageSize="2000000" maxStringContentLength="2000000" maxArrayLength="2000000" in both the configs. But, didn't work for me. – K S Jul 14 '14 at 22:39
  • Please make sure you had Common Configuration at WCF Service Layer and Client Consumer Layer and Second thing as Mentioned please check that quota is the same and increased to maximum – Ashok Rathod Jul 15 '14 at 06:34
  • Remember to change the max(params) in both your client and server... – Louis van Tonder Jul 15 '14 at 09:02
  • That is what I get confused about. In my service config file, where do I get to put the max(params)? – K S Jul 15 '14 at 15:03
  • Guys -you got any suggestions? – K S Jul 15 '14 at 23:00

1 Answers1

0

If error is about max reader quota, kindly make the change in web.config under your binding. See if it works.

<binding maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
      <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
        maxArrayLength="16348" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binding>
Aki
  • 149
  • 4
  • 13
  • My current client's config file looks like this: I am still not sure where to put in these max params in my services' config file. – K S Jul 15 '14 at 15:05
  • In your web.config file, there is tag, inside it tag would be there. Use this code in tag. – Aki Jul 16 '14 at 05:34