【问题标题】:Enabling readerQuotas on WCF GZip Encoder Custom Binding在 WCF GZip 编码器自定义绑定上启用 readerQuotas
【发布时间】:2010-07-13 04:01:44
【问题描述】:

我已经通过实现 MSDN 上的示例 GZip encoder 启用了我的 WCF 服务的压缩,并且一切正常,但是现在需要将我的读者配额转移到这个绑定中,因为我之前在我之前已经定制了这些使用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" />   

我已经尝试将此节点作为&lt;binding /&gt; 元素的子节点插入,并且我在&lt;gzipMessageEncoding /&gt; 元素之间看到了一个在线示例,这两个对我都不起作用返回错误:

System.Configuration.ConfigurationErrorsException: Unrecognized element 'readerQuotas'.

有什么想法吗?是否可以将读者配额与自定义绑定一起使用?我想它必须是,但这可能是一个类的变化,或者一个简单的方法来让它通过配置?希望一些 WCF 高手可以提供帮助:)

非常感谢, 格雷厄姆。

【问题讨论】:

  • 可能会尝试使用服务配置编辑器 - 不确定它是否支持自定义绑定,但值得一试:)
  • 谢谢,我们看了一下这里,似乎只列出了非常基础的绑定字段,不能设置读者配额的字段:(
  • 你想明白了吗?我怀疑随着时间的流逝,您发现了一些东西。解决方案是什么?

标签: .net wcf compression gzip wcf-binding


【解决方案1】:

看看这个帖子http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/633c5dc8-c134-40c9-9dfc-41a4b1cd3279/

您必须修改 GZipMessageEncodingElement 和 GZipMessageEncodingBindingElement 以公开 readerQuotas...

【讨论】:

    【解决方案2】:

    我能够以编程方式做到这一点:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-21
      • 2011-04-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多