在 WCF GZip 编码器自定义绑定上启用 readerQuotas

发布于 2024-09-09 08:25:28 字数 1563 浏览 2 评论 0原文

我通过实施示例 启用了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一人独醉 2024-09-16 08:25:28

看看这个线程 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...

摇划花蜜的午后 2024-09-16 08:25:28

我能够以编程方式执行此操作:

var gzipBindingElement = new GZipMessageEncodingBindingElement();
myBinding.ReaderQuotas.CopyTo((TextMessageEncodingBindingElement)gzipBindingElement.InnerMessageEncodingBindingElement).ReaderQuotas);

I was able to do this programmatically:

var gzipBindingElement = new GZipMessageEncodingBindingElement();
myBinding.ReaderQuotas.CopyTo((TextMessageEncodingBindingElement)gzipBindingElement.InnerMessageEncodingBindingElement).ReaderQuotas);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文