"最大字符串的内容长度配额(8192)时,超过了读取XML数据"错误在发送XML字符串到WCF字符串、配额、长度、错误

2023-09-03 03:15:07 作者:青

我使用的是.NET,C#应用程序,它打算长XML字符串发送到WCF服务方法,以便进行下一步操作。当我的应用程序试图以XML字符串发送到WCF服务在运行时,我得到一个错误信息:

I am working with a .NET, C# application which intends to send a long XML string to a WCF Service method for further operation. When my application tries to send the XML string to WCF Service in runtime, I am getting a error message :

的格式,而试图反序列化消息的异常:。有尝试反序列化参数http://tempuri.org/:strProdUserDataXML一个错误的InnerException消息是'有一个已经超过误差反序列化System.String类型的对象。最大字符串的内容长度配额(8192)读取XML数据时,该限额可提高通过更改XmlDictionaryReaderQuotas的MaxStringContentLength属性创建XML阅读器对象时使用。线131 ,位置57'。请参阅的InnerException更多细节。

我的应用程序方面的web.config我已经写了绑定&放大器; 端点为:

My application side web.config I have written the "binding" & "endpoint" as:

<binding name="EndPointHTTPGenericPortal" closeTimeout="01:00:00" openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
    <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    <security mode="None">
    <message clientCredentialType="UserName" algorithmSuite="Default" />
    </security>
    </binding>

    <endpoint address="http://192.168.140.40/WcfGenericPortal_Service/Service1.svc" binding="basicHttpBinding" bindingConfiguration="EndPointHTTPGenericPortal" contract="IService1" name="EndPointHTTPGenericPortal" behaviorConfiguration="Graph" />

如果任何机构可以帮助我如何解决这个错误,我将非常感谢。 感谢所有提前。

If any body can help me on how to solve this error I will be very much obliged. Thanks to all in advance.

推荐答案

下面是MSDN上关于的文章读者配额的。

Here is an article on MSDN about Reader Quotas.

看来,在你的服务器端的读者名额中的一个被超过。

It appears that one of the reader quotas on your server side is being exceeded.

具体而言, maxStringContentLength 被超过。默认值为 8192 字符的 maxStringContentLength 这是被超过所描述的错误消息。

Specifically, maxStringContentLength is being exceeded. The default value is 8192 characters for maxStringContentLength which as described by the error message is being exceeded.

但它可能不只是撞了所有值最大,最好的办法 2147483647 作为其他一些建议。

But it may not be the best approach to just bump up all the values to the maximum 2147483647 as some others have suggested.

由于写的MSDN文档,我链接了:

As written in the MSDN documentation that I linked:

复杂性的限制,从拒绝服务提供保障   (DOS)攻击,尝试使用信息的复杂性绑   端点的处理资源。其他的复杂性制约因素包括   如最大元件深度和最大长度为字符串的项目   该消息中的内容。

The complexity constraints provide protection from denial of service (DOS) attacks that attempt to use message complexity to tie up endpoint processing resources. Other complexity constraints include items such as a maximum element depth and a maximum length for string content within the message.

再加上事实,你现在有安全模式设置为无 - 你可能会在和自己的一些问题

Coupled with the fact that you currently have Security Mode set to None - you may be setting yourself up for some problems.