是否可以增加轮询双工绑定的最大字符串内容长度属性而不转换为自定义绑定?
我正在使用轮询双工绑定来进行 Silverlight 客户端应用程序和 WCF Web 服务之间的通信。我通过使用 xml 字符串参数从 Web 服务异步调用方法,将消息从 Silverlight Web 应用程序推送到 WCF Web 服务。一切都工作正常,直到我尝试发送一个非常大的 xml 字符串。然后我收到消息:
“格式化程序在尝试反序列化消息时抛出异常:操作“SendUserSelection”的请求消息正文反序列化时出错。读取 XML 时超出了最大字符串内容长度配额 (8192)可以通过更改创建 XML 读取器时使用的 XmlDictionaryReaderQuotas 对象的 MaxStringContentLength 属性来增加此配额。”
在这种情况下通常会增加web.config 文件中绑定的 maxStringContentLength 属性。这里的问题是,当尝试将 readerQuotas 元素(包含 maxStringContentLength)添加到绑定时,根本没有考虑到它。我发现这是一个已知问题:http://blogs.msdn.com/b/silverlightws/archive/2010/04/04/some-known-wcf-issues-in-silverlight-4.aspx 。给出的解决方案是使用包含轮询双工元素的自定义绑定。我尝试过,但不知怎的,我没有让它发挥作用。
我的问题是这个问题还有其他解决方法还是这是唯一的解决方案?
I am using Polling Duplex Binding for the communication between my Silverlight client application and my WCF web service. I push messages from the Silverlight web applciation to the WCF web service by calling asynchronously a method from the web service with an xml string parameter. Everything worked fine until I tried to send a really big xml string. Then I get the message:
"The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'SendUserSelection'. 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."
What is usually done in this case is increase the maxStringContentLength property for the binding in the web.config file. The problem here is that when trying to add the readerQuotas element (containing the maxStringContentLength) to the binding, it is not taken into consideration at all. I found that it is a known problem: http://blogs.msdn.com/b/silverlightws/archive/2010/04/04/some-known-wcf-issues-in-silverlight-4.aspx . The solution given there is to use a Custom Binding containing a Polling Duplex element. I tried that but somehow I didn't get it working.
My question is there some other workaround for this issue or is this the only solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,您确实需要进行自定义绑定。 PollingDuplexHttpBinding 类不会公开读取器配额,因此如果您遇到配额问题,则确实需要转到自定义绑定路由。
No, you really need to go to a custom binding. The PollingDuplexHttpBinding class does not expose the reader quotas, so if you have a quotas issue, you really need to go to the custom binding route.