在 WCF GZip 编码器自定义绑定上启用 readerQuotas
我通过实施示例 启用了 WCF 服务的压缩MSDN 上提供了 GZip 编码器,一切都运行良好,但现在需要将我的读者配额转移到此绑定,因为我之前在使用 wsHttpBinding
时已自定义了这些配额。
这是我在 wcf 服务的 Web.config
中声明的 GZip 绑定:
<customBinding>
<binding name="BufferedHttpCompressionBinding" closeTimeout="00:00:15"
openTimeout="00:00:15" receiveTimeout="00:00:15" sendTimeout="00:00:15">
<gzipMessageEncoding innerMessageEncoding="textMessageEncoding">
</gzipMessageEncoding>
<httpTransport maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647">
<extendedProtectionPolicy policyEnforcement="Never" />
</httpTransport>
</binding>
</customBinding>
正如您所看到的,没有读者配额,现在这是我要添加的 readerQuotas:
<readerQuotas
maxDepth="64"
maxStringContentLength="1048576"
maxArrayLength="1048576"
maxBytesPerRead="1048576"
maxNameTableCharCount="1048576" />
我已尝试插入此内容节点作为
元素的子级,而且我还在
元素之间看到了一个在线示例,两者都不是有两个工作为我返回错误:
System.Configuration.ConfigurationErrorsException: Unrecognized element 'readerQuotas'.
有什么想法吗?是否可以将读者配额与自定义绑定一起使用?我想它必须是这样,但这可能是一个类更改,或者是一种让它通过配置的简单方法?希望一些 WCF 高手可以提供帮助:)
非常感谢, 格雷厄姆.
I have enabled compression of my WCF service by implementing the sample GZip encoder featured on on MSDN and everything is working great, however now need to transfer my reader quotas across to this binding, as I previously had these customised when I was using wsHttpBinding
.
This is my GZip binding as declared in my Web.config
of the wcf service:
<customBinding>
<binding name="BufferedHttpCompressionBinding" closeTimeout="00:00:15"
openTimeout="00:00:15" receiveTimeout="00:00:15" sendTimeout="00:00:15">
<gzipMessageEncoding innerMessageEncoding="textMessageEncoding">
</gzipMessageEncoding>
<httpTransport maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647">
<extendedProtectionPolicy policyEnforcement="Never" />
</httpTransport>
</binding>
</customBinding>
As you can see without the reader quotas, now here are the readerQuotas that I would like to add:
<readerQuotas
maxDepth="64"
maxStringContentLength="1048576"
maxArrayLength="1048576"
maxBytesPerRead="1048576"
maxNameTableCharCount="1048576" />
I have tried inserting this node as a child of the <binding />
element, and also I saw an example online of it between the <gzipMessageEncoding />
element, neither of the two work for me returning an error:
System.Configuration.ConfigurationErrorsException: Unrecognized element 'readerQuotas'.
Any thoughts? Is it possible to use reader quotas with custom bindings? I imagine it would have to be, but might this be a class change, or a simple way to get it going through config? Hopefully some WCF whiz can help :)
Many thanks,
Graham.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看看这个线程 http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/633c5dc8-c134-40c9-9dfc-41a4b1cd3279/
您必须修改 GZipMessageEncodingElement 和 GZipMessageEncodingBindingElement 以公开 readerQuotas...
Have a look at this thread http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/633c5dc8-c134-40c9-9dfc-41a4b1cd3279/
You have to modify GZipMessageEncodingElement and GZipMessageEncodingBindingElement to expose readerQuotas...
我能够以编程方式执行此操作:
I was able to do this programmatically: