我可以轻松检索大量数据,但将其发回服务会显示此错误。
格式化程序在尝试反序列化消息时抛出异常:尝试反序列化参数http://tempuri.org/:response时出错。 InnerException消息是'反序列化System.String类型的对象时出错。读取XML数据时已超出最大字符串内容长度配额(8192)。通过更改创建XML阅读器时使用的XmlDictionaryReaderQuotas对象的MaxStringContentLength属性,可以增加此配额。
以下是我在WCF服务(服务器)上的内容:
<bindings>
<basicHttpBinding>
<binding name="BasicHTTPEndpoint" maxBufferSize="2147483647" maxBufferPoolSize="524288"
maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://192.168.1.99/Service/SerializerJsonService"
binding="basicHttpBinding" bindingConfiguration="HandleLargeMessage"
contract="XMLService.IXMLReader" name="BasicHTTPEndpoint" />
</client>
和servicereferences.clientconfig:
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ISerializerJsonService" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://192.168.1.99/Service/SerializerJsonService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISerializerJsonService"
contract="YelpService.ISerializerJsonService" name="BasicHttpBinding_ISerializerJsonService" />
</client>
</system.serviceModel>
答案 0 :(得分:6)
在服务器配置中:
<basicHttpBinding>
<binding name="BasicHTTPEndpoint"...
应该是
<basicHttpBinding>
<binding name="HandleLargeMessage"...
以便端点将使用该绑定(您在BindingConfiguration="HandleLargeMessage"
中指定,name属性仅在此处命名端点)
答案 1 :(得分:0)
我认为问题出在maxBytesPerRead="4096"