我们试图向WCF中的服务方法发送一个大的xml字符串,并且我们得到了错误
读取XML数据时已超出最大字符串内容长度配额(8192)。
这个错误意味着增加maxstringcontentlength,尽管我们不确定我们是否应该在客户端或服务器端,或者两者兼而有之。我们试过把这两种方法都放进去,但似乎还是会犯错误的。我将把客户和服务吐露在下面。我想他们中的一人或两人都有问题来阻止他们的工作。
有什么建议吗?
客户端:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ITESTService"
closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288"
maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8"
transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="4096"
maxNameTableCharCount="2147483647" />
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint name="BasicHttpBinding_ITESTService"
address="http://localhost/TESTService.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_ITESTService"
contract="TESTService.ITESTService" />
</client>
</system.serviceModel>服务器:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding
name="BasicHttpBinding_Service1"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32"
maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="4096" maxNameTableCharCount="2147483647" />
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="TESTService">
<endpoint name="BasicHttpBinding_Service1"
address="http://localhost/TESTService.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_Service1"
contract="ITESTService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>发布于 2011-01-29 10:33:13
此线程详细说明如何正确指定服务器和客户端上的绑定设置,以更改MaxStringContentLength。
另一个线程还提供了一个关于使用readerQuotas的清晰而高效的答案。
发布于 2011-11-04 11:18:17
尝试添加“默认”绑定(没有指定任何名称)。将readerQuota设置添加到此绑定中。
然后,您甚至可以从实际使用的命名绑定中删除readerQuota设置。
这对我有效(虽然我不知道为什么WCF忽略了正确命名绑定上的readerQuotas )
发布于 2013-06-25 07:17:29
“默认”绑定选项对我有效。我尝试在命名的maxStringContentLength中自定义WebHttpBinding值,但由于某种原因,WCF没有选择它。最后,我跟踪了D.Tiemstra的工作,然后它开始工作。
<webHttpBinding>
<binding maxReceivedMessageSize="2147483647" >
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</webHttpBinding>https://stackoverflow.com/questions/4834489
复制相似问题