.net – WCF : How to Set MaxReceivedMessageSize Quota

.net-4.0asp.netasp.net-4.0netwcf

I have a WCF Service. I get the following message when I run the client application

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.

Also i added MaxReceivedMessageSize property in related config in client and server projects.

My config in client application is :

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="RPBasicHttpBinding" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000">
          <readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:40003/PersonWcfService.svc/PersonServices"
        binding="basicHttpBinding"
        contract="RP.Common.ServiceContract.IPersonService" name="BasicHttpBinding_IPersonService">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>

My config in WCF project is :

<system.serviceModel>
    <services>
      <service name="RP.WcfService.PersonWcfService" behaviorConfiguration="RP.WcfServiceBehaviour">
        <endpoint address="PersonServices" binding="basicHttpBinding" bindingConfiguration="RPBasicHttpEndpointBinding" contract="RP.Common.ServiceContract.IPersonService" />
      </service>
    </services>
    <behaviors>
    <serviceBehaviors>
      <behavior name="RP.WcfServiceBehaviour">
        <serviceMetadata httpGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="true" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
    <bindings>
      <basicHttpBinding>
        <binding name="RPBasicHttpEndpointBinding" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000">
          <readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/>
        </binding>
      </basicHttpBinding>
    </bindings>
  </system.serviceModel>

Where other is then i should set MaxReceivedMessageSize property to increase message size quota?

Best Answer

Aren't you missing bindingConfiguration="RPBasicHttpBinding" in your endpoint configuration on the client side... and thus getting a default configuration of the basicHttpBinding instead of your specified configuration?