December 2009 - Posts

GZip Encoder WCF XmlDictionaryReaderQuotas MaxStringContentLength 8192 Error

 

I used a MessageEncoder from Microsoft samples that you can find on this link.

But when i processed big message it didn't work for an error similar to this:

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.

I found some solutions but every solutions doesn't work, so I changed code for resolve problem:

Go to file GZipMessageEncodingBindingElement in class GZipMessageEncodingBindingElement, find method ApplyConfiguration and change it as follow:

 

//Called by the WCF to apply the configuration settings (the property above) to the binding element
public override void ApplyConfiguration(BindingElement bindingElement)
{
GZipMessageEncodingBindingElement binding = (GZipMessageEncodingBindingElement)bindingElement;
PropertyInformationCollection propertyInfo = this.ElementInformation.Properties;
if (propertyInfo["innerMessageEncoding"].ValueOrigin != PropertyValueOrigin.Default)
{
switch (this.InnerMessageEncoding)
{
case "textMessageEncoding":
TextMessageEncodingBindingElement encoder = new TextMessageEncodingBindingElement();
encoder.ReaderQuotas.MaxStringContentLength = int.MaxValue;
binding.InnerMessageEncodingBindingElement = encoder;
break;
case "binaryMessageEncoding":
BinaryMessageEncodingBindingElement binEncoder = new BinaryMessageEncodingBindingElement();
binEncoder.ReaderQuotas.MaxStringContentLength = int.MaxValue;
binding.InnerMessageEncodingBindingElement = binEncoder;
break;
}
}
else {
TextMessageEncodingBindingElement encoder = new TextMessageEncodingBindingElement();
encoder.ReaderQuotas.MaxStringContentLength = int.MaxValue;
binding.InnerMessageEncodingBindingElement = encoder;
}
}

It works for text encoding and binary encoding.

Bye

Antonio

Posted 30 December 2009 12:03 AM by antrad | no comments
Filed under:

This site

Search

Go

This Blog

Syndication

Sponsors

  • MaximumASP
  • Social Bookmarking
    Online Shopping
    asp.net hosting
    UK online local dating