14

This morning I ran into an issue with returning back a text string as result from a Web Service call. the Error I was getting is below

************** Exception Text **************
System.ServiceModel.CommunicationException: Error in deserializing body of reply message for operation 'GetFilingTreeXML'. ---> System.InvalidOperationException: There is an error in XML document (1, 9201). ---> System.Xml.XmlException: 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 1, position 9201.
at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, String res, String arg1, String arg2, String arg3)
at System.Xml.XmlExceptionHelper.ThrowMaxStringContentLengthExceeded(XmlDictionaryReader reader, Int32 maxStringContentLength)
at System.Xml.XmlDictionaryReader.ReadString(Int32 maxStringContentLength)
at System.Xml.XmlDictionaryReader.ReadString()
at System.Xml.XmlBaseReader.ReadElementString()
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderImageServerClientInterfaceSoap.Read10_GetFilingTreeXMLResponse()
at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer9.Deserialize(XmlSerializationReader reader)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
at System.ServiceModel.Dispatcher.XmlSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, XmlSerializer serializer, MessagePartDescription returnPart, MessagePartDescriptionCollection bodyParts, Object[] parameters, Boolean isRequest)
--- End of inner exception stack trace ---

I did a search and the results are below: Search Results

Most of those are WCF related but were enough to point me in the right direction. I will post answer as reply.

Tim B
  • 40,716
  • 16
  • 83
  • 128
MikeScott8
  • 720
  • 2
  • 10
  • 17
  • re: your flag; its more complicated than that. Please ask on [meta]. –  Aug 08 '11 at 11:47
  • Sorry for asking the obvious: Can you check that the string you are returning from the web service is longer than 8192 bytes? – Espo Sep 15 '08 at 18:38
  • yes it was longer and I had to update the config file, as mentioned in linked blog post, and that fixed it. thanks for the reply – MikeScott8 Sep 15 '08 at 19:45

2 Answers2

29

Try this blog post here. You can modify the MaxStringContentLength property in the Binding configuration.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Darrel Miller
  • 139,164
  • 32
  • 194
  • 243
  • yes it was the solution, I had to update the config file, as mentioned in linked blog post, and that fixed it. thanks for the reply – MikeScott8 Sep 15 '08 at 19:45
  • 3
    Just as a note for clarity, the reader quota settings have to be made in the app.config or web.config for the side of the communication which will be receiving the large string. i.e. I needed to send a large amount of data from my client app to my service endpoint, thus I had to make the changes in the web.config file for the service. Returning large data from the service to the client app required changes in the app.config of the client. Hope this helps someone else. – kirps Oct 11 '11 at 17:58
6

Jow Wirtley's blog post pointed me in the right direction.

All I had to do was update the bindings in the app.config of the client app and it all works now.

hichris123
  • 10,145
  • 15
  • 56
  • 70
MikeScott8
  • 720
  • 2
  • 10
  • 17