Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF Error - The maximum message size quota for incoming messages (65536) has been exceeded [duplicate]

Tags:

My Setup:

  • ASP.NET client hosted in IIS Express
  • WCF Service hosted in Console Application
  • Running Visual Studio.NET 2012 in Admin mode

I am trying to return 2 List objects from a WCF service. My setup WORKS FINE when I return just 1 List objects. But when I return 2 List objects I get the error:

The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.

I know that this question has been asked many times on this site and other sites as well. I have tried almost everything posted on the internet with various combinations of the CONFIG FILE but still this has not worked out for me.

Client Config:

<configuration>     <system.web>         <compilation debug="true" targetFramework="4.0" />         <httpRuntime maxRequestLength="1572864"/>     </system.web>      <system.serviceModel>         <client>             <endpoint name="basicHttpBinding"                 address="http://localhost:9502/HCDataService"                 binding="basicHttpBinding"                 bindingConfiguration="basicHttpBinding"                                 contract="HC.APP.Common.ServiceContract.IHCServiceContract"                 behaviorConfiguration="ServiceBehaviour">             </endpoint>         </client>          <bindings>             <basicHttpBinding>                 <binding name="basicHttpBinding" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647">                     <readerQuotas maxDepth="128" maxStringContentLength="2147483647" maxArrayLength="2147483646" maxBytesPerRead="4096" maxNameTableCharCount="16384" />                 </binding>             </basicHttpBinding>         </bindings>          <behaviors>             <endpointBehaviors>                 <behavior name="ServiceBehaviour">                     <dataContractSerializer maxItemsInObjectGraph="2147483647"/>                 </behavior>             </endpointBehaviors>         </behaviors>     </system.serviceModel> </configuration> 

Server Config:

<configuration>     <system.serviceModel>         <services>             <service name="HC.APP.Server.Service.HCDataService" behaviorConfiguration="ServiceBehaviour">                 <host>                     <baseAddresses>                         <add baseAddress="http://localhost:9502/HCDataService"/>                     </baseAddresses>                 </host>                  <endpoint name="basicHttpBinding"                     address="http://localhost:9502/HCDataService"                     binding="basicHttpBinding"                     bindingConfiguration="basicHttpBinding"                     contract="HC.APP.Common.ServiceContract.IHCServiceContract">                 </endpoint>             </service>         </services>          <bindings>             <basicHttpBinding>                 <binding name="basicHttpBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" closeTimeout="01:50:00" openTimeout="01:50:00" sendTimeout="01:50:00" receiveTimeout="01:50:00" >                     <readerQuotas maxDepth="128" maxStringContentLength="8388608" maxArrayLength="2147483646" maxBytesPerRead="4096" maxNameTableCharCount="16384" />                 </binding>             </basicHttpBinding>         </bindings>          <behaviors>             <serviceBehaviors>                 <behavior name="ServiceBehaviour">                     <serviceDebug includeExceptionDetailInFaults="true" />                     <serviceMetadata httpGetEnabled="true" />                     <dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483646" />                 </behavior>             </serviceBehaviors>         </behaviors>         </system.serviceModel> </configuration> 
like image 698
Yuvi Dagar Avatar asked Apr 28 '13 17:04

Yuvi Dagar


1 Answers

That would be because you didn't specify on the server which binding to use. Let's take a look at your server config:

Under <bindings> you are creating a binding configuration for <basicHttpBinding>, and you are naming it name="basicHttpBinding". Also, your endpoint name is <endpoint name="basicHttpBinding" ...> and its binding is binding="basicHttpBinding". However, it's not referring to your binding configuration, but to the binding type. So, it's actually using the default settings for basicHttpBinding.

To fix this, first of all name your endpoint and binding configuration differently. For example, <endpoint name="basicEndpoint" ... > and <binding name="myBasicBinding" ... >. Then you need to assign your binding configuration to your endpoint with this attribute: bindingConfiguration="myBasicBinding".

Here's the client config:

<system.web>     <httpRuntime maxRequestLength="32768"/> </system.web>  <system.serviceModel>     <client>         <endpoint name="basicEndpoint"             address="http://localhost:9502/HCDataService"             binding="basicHttpBinding"             bindingConfiguration="myBasicBinding"             contract="HC.APP.Common.ServiceContract.IHCServiceContract"             behaviorConfiguration="ServiceBehaviour">         </endpoint>     </client>      <bindings>         <basicHttpBinding>             <binding name="myBasicBinding" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647">                 <readerQuotas maxDepth="128" maxStringContentLength="2147483647" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />             </binding>         </basicHttpBinding>     </bindings>      <behaviors>         <endpointBehaviors>             <behavior name="ServiceBehaviour">                 <dataContractSerializer maxItemsInObjectGraph="2147483647"/>             </behavior>         </endpointBehaviors>     </behaviors>     </system.serviceModel> 

Here's the server config:

<system.serviceModel>     <services>         <service name="HC.APP.Server.Service.HCDataService" behaviorConfiguration="ServiceBehaviour">             <host>                 <baseAddresses>                     <add baseAddress="http://localhost:9502/HCDataService"/>                 </baseAddresses>             </host>              <endpoint name="basicEndpoint"                 address="http://localhost:9502/HCDataService"                 binding="basicHttpBinding"                 bindingConfiguration="myBasicBinding"                 contract="HC.APP.Common.ServiceContract.IHCServiceContract">             </endpoint>         </service>     </services>      <bindings>         <basicHttpBinding>             <binding name="myBasicBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" closeTimeout="01:50:00" openTimeout="01:50:00" sendTimeout="01:50:00" receiveTimeout="01:50:00" >                 <readerQuotas maxDepth="128" maxStringContentLength="8388608" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />             </binding>         </basicHttpBinding>     </bindings>      <behaviors>         <serviceBehaviors>             <behavior name="ServiceBehaviour">                 <serviceDebug includeExceptionDetailInFaults="true" />                 <serviceMetadata httpGetEnabled="true" />                 <dataContractSerializer ignoreExtensionDataObject="false" maxItemsInObjectGraph="2147483646" />             </behavior>         </serviceBehaviors>     </behaviors> </system.serviceModel> 

Don't forget to update service reference on your client to get the correct config.

like image 167
Artless Avatar answered Oct 11 '22 20:10

Artless