MaxReceivedMessageSize error in WCF

11,834

You need to make the change on both sides - server and client - but you need to make it to the appropriate binding - the one your service (and client) are actually using!

So in your case, on your server-side, the service is configured to use wsHttpBinding:

<service name="WcfServiceZone_Store.Service1" behaviorConfiguration="metadataBehavior">
   <endpoint address="" binding="wsHttpBinding" contract="WcfServiceZone_Store.IService1">
                                 *************

but you've defined the higher values on the basicHttpBinding ..... that won't work, of course!

<bindings>
   <basicHttpBinding>
    ****************   this doesn't match with the defined binding on your endpoint!

And you're also not referencing the new binding configuration you've defined - you need to TELL WCF to actually use those new binding values!

So you need to do this on the server:

<system.serviceModel>
<bindings>
  <wsHttpBinding>
    <binding name="BindingWithMaxSizeIncreased" 
         maxBufferPoolSize="2147483647" 
         maxReceivedMessageSize="2147483647">
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
              maxArrayLength="2147483647" maxBytesPerRead="2147483647" 
              maxNameTableCharCount="2147483647" />
    </binding>
  </wsHttpBinding>
</bindings>

<services>
  <service name="WcfServiceZone_Store.Service1" behaviorConfiguration="metadataBehavior">
    <!-- Service Endpoints -->
    <endpoint 
        address="" 
        binding="wsHttpBinding" 
        bindingConfiguration="BindingWithMaxSizeIncreased"  -- use those new values!
        contract="WcfServiceZone_Store.IService1">
      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>

Same thing on the client-side:

  • define the binding parameters for the correct binding (wsHttpBinding - not basicHttpBinding)
  • add a reference to the bindingConfiguration to the <endpoint> so that those values will actually be used
Share:
11,834
vivek jain
Author by

vivek jain

Updated on July 16, 2022

Comments

  • vivek jain
    vivek jain almost 2 years

    As Im new to WCF, please help me out. I am getting this error. I have searched on internet for this problem and I have got many solution, but when I applied those solutions. some new problems I am facing. So please provide me a valid solution.

    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.

    Service Web.config file.

    <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="WSHttpBinding_IService1" maxBufferSize="2147483647"
          maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="WcfServiceZone_Store.Service1" behaviorConfiguration="metadataBehavior">
        <!-- Service Endpoints -->
        <endpoint address="" binding="wsHttpBinding" contract="WcfServiceZone_Store.IService1">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="metadataBehavior">
          <!-- 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>
    

    Client Web.config file:

    <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="WSHttpBinding_IService1" maxBufferSize="2147483647"
          maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:50274/Service1.svc" binding="wsHttpBinding" contract="ServiceReference1.IService1">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
    </client>
    

    please tell me, on which side I need to make changes.