.net – WCF – Win App “The maximum string content length quota (8192) has been exceeded while reading XML data.”

netwcf

I am having some problem while implementing Web Service through WCF. While I m passing value in WCF method from client application as a string (xml), getting error

The formatter threw an exception
while trying to deserialize the
message: There was an error while
trying to deserialize parameter
http://tempuri.org/:XmlEntity.

The InnerException message was

'There was an error deserializing the
object of type System.String. 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. Line
249, position 19.'.

I have tried to change the value of maxStringContentLength in client web.configuration file but error is remains same. Kindly try to find out the solution asap.

Best Answer

Ashish, Darin means that you should've created a basicHttpBinding to override and increase the value of maxStringContentLength to 2147483647. Can you confirm whether you've configured you endpoint to use the same binidng with bindingConfiguration attribute. For example, you've created a binding like this,

<basicHttpBinding>
   <binding name="HandleLargeMessage" maxReceivedMessageSize="2147483647">         
      <readerQuotas maxDepth="2147483647"
         maxStringContentLength="2147483647"
         maxArrayLength="2147483647"
         maxBytesPerRead="2147483647"
         maxNameTableCharCount="2147483647" /> 
   </binding>

You can configure endpoint to use above binding configuration like this, (please note the bindingConfiguration attribute)

<endpoint  
     address="....."
     binding="basicHttpBinding" bindingConfiguration="HandleLargeMessage" 
     contract="xxx" />

Can you confirm whether you've already done that? very likely that doesn't seem to be the case here.

If you've already followed this and would like to confirm whether it's used, capture WCF traces for service and client application at verbose level and check the activities in Construct Host at sevice and Construct channel at client application.

Related Topic