4

我最近將一些Silverlight 3 WCF服務轉換爲使用新的二進制http綁定。長字符串通常會發送到服務器以便在這些服務中進行反序列化,並且以前我曾經用它來確保數據可以正確讀取。然而,隨着新的綁定我無法找到正確的位置要添加的元素:如何增加服務器端的二進制Http綁定MaxStringContentLength

 <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。因此,只使用二進制編碼,我如何增加閱讀器配額以允許大型字符串的反序列化?

回答

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> 
相關問題