I have enabled compression of my WCF service by implementing the sample GZip encoder featured on on MSDN and everyth开发者_JAVA技巧ing 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.
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:
var gzipBindingElement = new GZipMessageEncodingBindingElement();
myBinding.ReaderQuotas.CopyTo((TextMessageEncodingBindingElement)gzipBindingElement.InnerMessageEncodingBindingElement).ReaderQuotas);
精彩评论