当前位置:  开发笔记 > Android > 正文

在WebService调用中序列化字符串时出错

如何解决《在WebService调用中序列化字符串时出错》经验,为你挑选了2个好方法。

今天早上我遇到了一个问题,即返回一个文本字符串作为Web Service调用的结果.我得到的错误是在下面

************** 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 ---

我进行了搜索,结果如下: 搜索结果

其中大部分与WCF有关,但足以指出我正确的方向.我会发回答作为回复.



1> Darrel Mille..:

在这里试试这篇博文.您可以在Binding配置中修改MaxStringContentLength属性.


为了清楚起见,读者配额设置必须在app.config或web.config中进行,以便通信接收大字符串.即我需要从我的客户端应用程序向服务端点发送大量数据,因此我必须在服务的web.config文件中进行更改.将大数据从服务返回到客户端应用程序需要更改客户端的app.config.希望这有助于其他人.

2> MikeScott8..:

Jow Wirtley的博客文章指出了我正确的方向.

我所要做的就是更新客户端应用程序的app.config中的绑定,现在一切正常.

推荐阅读
kikokikolove
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有