The maximum message size quota for incoming messages (65536) has been exceeded

08 Jan

Recently I was developing a SharePoint timer Job that references a WCF Service to retrieve some information. I was getting the following message –

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.

The increase the MaxReceivedMessageSize you normally change the configuration file as follows –

<binding name=”BasicHttpBinding_MyService” maxBufferSize=”2147483647″ maxReceivedMessageSize=”2147483647″ />

But I was writing SharePoint timer Job and the timer job normally uses the owstimer.exe.config file. The file is located at C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN

I was not in favor of changing the config file so I wrote the following code to set the maxReceivedMessageSize –

BasicHttpBinding binding = new BasicHttpBinding();
binding.MaxBufferSize = 2147483647;
binding.MaxReceivedMessageSize = 2147483647;
EndpointAddress remoteAddress = new EndpointAddress(“<your service URL>”);
MyService.ServiceClient service = new MyService.ServiceClient(binding, remoteAddress);
MyService.fieldResponse fieldResponse = service.<Method>;

Happy coding….

Leave a comment

Posted by on January 8, 2014 in Uncategorized


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: