我已经通过实现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" /> 我曾尝试将此节点作为<binding />元素的子节点插入,我还在<gzipMessageEncoding />元素之间在线看到了它的一个示例,这两种方法都不适合我,并返回一个错误:
System.Configuration.ConfigurationErrorsException: Unrecognized element 'readerQuotas'.有什么想法吗?是否可以对自定义绑定使用读取器配额?我想这是必须的,但这可能是类的改变,或者是通过配置的简单方法?希望一些WCF高手能帮上忙:)
非常感谢,格雷厄姆。
发布于 2010-11-16 08:05:10
看一下这个线程http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/633c5dc8-c134-40c9-9dfc-41a4b1cd3279/
您必须修改GZipMessageEncodingElement和GZipMessageEncodingBindingElement以公开readerQuotas...
发布于 2014-04-04 14:43:41
我能够以编程的方式做到这一点:
var gzipBindingElement = new GZipMessageEncodingBindingElement();
myBinding.ReaderQuotas.CopyTo((TextMessageEncodingBindingElement)gzipBindingElement.InnerMessageEncodingBindingElement).ReaderQuotas);https://stackoverflow.com/questions/3234106
复制相似问题