Monday, December 7, 2015

WCF : 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 encountered the WCF message size exception, while pulling more than 2K records from database

Exception: 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.

As per error message, the value of MaxReceivedMessageSize property should be increased to resolve this problem. by default, the value of MaxReceivedMessageSize is 65536 and we can change its value to integer max size (2147483647)

<basicHttpBinding><binding name="BasicHttpBindingService"  maxReceivedMessageSize="2147483647" maxBufferSize="65536  transferMode="Buffered/>   </basicHttpBinding>



by default transferMode is "Bufferd", then you will get another exception

Exception: For TransferMode.Buffered, MaxReceivedMessageSize and MaxBufferSize must be the same value. Parameter name: bindingElement

As per error  message, if TransferMode is Buffered the both MaxReceivedMessageSize and MaxBufferSize  value should be same.

<basicHttpBinding><binding name="BasicHttpBindingService"  maxReceivedMessageSize="2147483647" maxBufferSize="2147483647 transferMode="Buffered/>   </basicHttpBinding>

For more information about Transfer Mode, please visit on this url (WCF Transfer Mode)

If you are still getting this message size issue, then you should explore the other message encoding pattern, by default it is Text\XML, you can choose MTMO or Binary encoding pattern.

What is MTOM? 

MTOM is an efficient technology for transmitting binary data in WCF messages and  MTOM encoder attempts to create a balance between efficiency and interoperability. The MTOM encoding transmits most XMLin textual form, but optimizes large blocks of binary data by transmitting them as-is, without conversion to text and for more information please visit on this url (WCF MTOM MessageEncoding)

Thanks for Visiting!!

No comments:

SQL Server - Identify unused indexes

 In this blog, we learn about the index usage information (SYS.DM_DB_INDEX_USAGE_STATS) and analyze the index usage data (USER_SEEKS, USER_S...