Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increase MaxStringContentLength on the server side for binary Http binding

I recently converted some Silverlight 3 WCF services to use the new binary http bindings. Long strings are often sent over to the server for deserialization in these services and I previously used to ensure the data could be read properly. However, with the new binding I can't find the correct place to add the element:

      <customBinding>
        <binding name="binaryHttpBinding">
          <binaryMessageEncoding maxReadPoolSize="2147483647" maxSessionSize="2147483647" maxWritePoolSize="2147483647"/>
          <httpTransport maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"/>
        </binding>
      </customBinding>

Here's one attempt:

      <customBinding>
        <binding name="binaryHttpBinding">
          <binaryMessageEncoding maxReadPoolSize="2147483647" maxSessionSize="2147483647" maxWritePoolSize="2147483647"/>
          <httpTransport maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"/>
          <textMessageEncoding>
            <readerQuotas maxDepth="32" maxStringContentLength="5242880"
            maxArrayLength="200000" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          </textMessageEncoding>
        </binding>
      </customBinding>

That caused other problems - it doesn't seem like a good idea to have a binary encoding and a textMessageEncoding in the same binding. So using only the binary encoding, how can I increase the reader quotas to allow deserialization of large strings?

like image 323
James Cadd Avatar asked Dec 17 '22 06:12

James Cadd


1 Answers

Here's the solution I found:

      <customBinding>
        <binding name="binaryHttpBinding">
          <binaryMessageEncoding maxReadPoolSize="2147483647" maxSessionSize="2147483647" maxWritePoolSize="2147483647">
            <readerQuotas maxDepth="32" maxStringContentLength="5242880"
            maxArrayLength="200000" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          </binaryMessageEncoding>
          <httpTransport maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"/>
        </binding>
      </customBinding>
like image 124
James Cadd Avatar answered May 16 '23 07:05

James Cadd