This is a mirror of official site: http://jasper-net.blogspot.com/

WCF Client Fault Size Limit

| Sunday, August 8, 2010
Configuring WCF message quotas on the server and client sides is not a trivial task. There are quite a few settings that you can tweak, including limits for a single string’s length in a message, the number of objects in the serialization graph, the serialization depth, and the array size.

However, there’s one limit my service hit a few days ago that I wasn’t at all aware of—I didn’t even realize there was a reason for it to exist. Consider the following service method:

public string Foo(bool throwFault, int stringLength)
{
   string s = new string('A', stringLength);
           
   if (throwFault)
       throw new FaultException<string>(s);

   return s;
}
And the following service method invocation:

proxy.Foo(false, 10000);
The service host is using the NetTcpBinding, with the default configuration settings. The result of the previous line would be the following exception:

System.ServiceModel.CommunicationException: Error in deserializing body of reply message for operation 'Foo'. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader.

All righty then, off we go and change the MaxStringContentLength property to 200K. The above now works, but the following fails:

proxy.Foo(false, 100000);
This time, we’re hitting this:

System.ServiceModel.CommunicationException: 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.

Read more: All Your Base Are Belong To Us

Posted via email from .NET Info

0 comments: