我最近转换了一些Silverlight 3 WCF服务以使用新的二进制http绑定。长字符串经常被发送到服务器以便在这些服务中进行反序列化,之前我曾用它来确保可以正确读取数据。但是,使用新绑定我找不到添加元素的正确位置:
<customBinding>
<binding name="binaryHttpBinding">
<binaryMessageEncoding maxReadPoolSize="2147483647" maxSessionSize="2147483647" maxWritePoolSize="2147483647"/>
<httpTransport maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"/>
</binding>
</customBinding>
这是一次尝试:
<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>
这导致了其他问题 - 在同一个绑定中使用二进制编码和textMessageEncoding似乎不是一个好主意。因此,仅使用二进制编码,如何增加读取器配额以允许对大字符串进行反序列化?
答案 0 :(得分:12)
以下是我找到的解决方案:
<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>