.net - WCF - 赢取应用程序 “The maximum string content length quota (8192) has been exceeded while reading XML data.”

标签 .net wcf

我在通过 WCF 实现 Web 服务时遇到了一些问题。当我从客户端应用程序将 WCF 方法中的值作为字符串 (xml) 传递时,出现错误

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:XmlEntity.


InnerException消息是

'There was an error deserializing the object of type System.String. 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 249, position 19.'.



我试图在客户端 web.configuration 文件中更改 maxStringContentLength 的值,但错误仍然相同。请尝试尽快找出解决方案。

最佳答案

Ashish,Darin 的意思是您应该创建一个 basicHttpBinding 来覆盖并将 maxStringContentLength 的值增加到 2147483647。您能否确认您是否已将端点配置为使用具有 bindingConfiguration 属性的相同 binidng。例如,您创建了这样的绑定(bind),

<basicHttpBinding>
   <binding name="HandleLargeMessage" maxReceivedMessageSize="2147483647">         
      <readerQuotas maxDepth="2147483647"
         maxStringContentLength="2147483647"
         maxArrayLength="2147483647"
         maxBytesPerRead="2147483647"
         maxNameTableCharCount="2147483647" /> 
   </binding>

您可以像这样配置端点以使用上述绑定(bind)配置,(请注意 bindingConfiguration 属性)
<endpoint  
     address="....."
     binding="basicHttpBinding" bindingConfiguration="HandleLargeMessage" 
     contract="xxx" />

你能确认你是否已经这样做了吗?很可能这里似乎并非如此。

如果您已经按照此操作并想确认它是否已被使用,请在详细级别捕获服务和客户端应用程序的 WCF 跟踪,并检查在服务端构造主机和在客户端应用程序构造 channel 中的事件。

关于.net - WCF - 赢取应用程序 “The maximum string content length quota (8192) has been exceeded while reading XML data.”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4906128/

相关文章:

c# - WCF 异步服务器端 - 正确实现

wcf - WcfAzureSamples 上缺少 Microsoft.ServiceHosting.ServiceRuntime

Java 服务 - SOAP 响应始终向 .NET 返回 NULL

c# - 如何诊断 "The instruction at 0x......... referenced memory at 0x00000000"

c# - Combobox 上的自动完成 onkeypress 事件吃掉了 Enter 键

c# - TinyMapper:使用表达式绑定(bind)

wcf - WCF 中的自签名证书问题 - 必须有私钥

.net - 如何获取托管对象的引用计数?

c# - WCF数据同步

c# - 为什么我的 IAuthorizationPolicy 没有使用我的 CustomPrincipal 设置 Thread.CurrentPrincipal?