views:

4531

answers:

2

I have a WCF Service which returns 1000 records from database to the client. I have a ASP.NET WCF client - ( i have added service reference in asp.net web application project to consume WCF). 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.

Any Help ? How to increase message size quota ?

+16  A: 

You'll want something like this:

<bindings>
    <basicHttpBinding>
        <binding name="basicHttp" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000">
            <readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/>
        </binding>
    </basicHttpBinding>
</bindings>
Nate Bross
Thanks..This change is needs to be made in web.config file of client application.
bugBurger
You may also need to change it on the server -- in the event you need to send in a large dataset as a parameter to a WCF Method.
Nate Bross
Any particular reason for the message size of 20000000?
Brian Vander Plaats
Its sufficently large to accomidate most messages. You can tune that number to fit your needs. It is basically there to prevent DOS type attacks. Making it 20000000 would allow for a distributed DOS attack to be effective, the default size of 64k would require a very large number of clients to overpower most servers these day.s
Nate Bross
For others who are interested, I read on another blog that the maximum size is 2147483647. 20000000 is a bit smaller than this number, so using the smallest number you can get away with without interrupting service makes sense.
proudgeekdad
+1  A: 

If you're still getting this error message while using the WCF Test Client, it's because it has it's own MaxBufferSize setting. Right-Click on the Config File node at the bottom of the tree and select Edit with SvcConfigEditor.

A list of editable settings will appear, including MaxBufferSize.

Also, auto-generated proxy clients also set MaxBufferSize to 65536 by default.

Michael Rodrigues