The maximum string content length quota (8192) has been exceeded while reading XML data

前端 未结 2 1487
孤街浪徒
孤街浪徒 2020-11-27 21:34

I\'m trying to pass a large string (24,000 to 50,000 characters) to a self-hosted TCP WCF service.

I\'ve upped the maxStringContentLength (everywhere) to 22008192.

相关标签:
2条回答
  • 2020-11-27 22:00

    The bindingConfiguration needs to have the name you assign to the netTcpinding element - "LargeBuffer" or "LongFields" won't mean anything unless there is a binding element in the config file with that name. That is why your service won't start when you put that in - you most likely got a configuration error message of some sort, I bet.

    To override the default 8192 setting for maxStringContentLength do this:

    1. Create a Binding element in the config file that has the size you want for maxStringContentLength and give it a name in the name attribute.
    2. In the endpoint element, assign the name from step 1 above to the attribute bindingConfiguration.

    If you don't specify a binding configuration for the endpoint, the service will use the default values.

    For example, take your config file above. Under the tag, add the following binding configuration (note that your specific values and the optional attributes you use will vary depending on the needs of your service):

    <bindings>
      <netTcpBinding>
        <binding name="ExStreamWCFBinding" closeTimeout="00:00:05" openTimeout="00:00:05" receiveTimeout="00:00:05" sendTimeout="00:00:05" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparison="StrongWildCard" maxBufferPoolSize="524288" maxBufferSize="524288" maxConnections="10" maxReceivedMessageSize="5242880">
          <readerQuotas maxDepth="32" maxStringContentLength="5242880" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
        </binding>
      </netTcpBinding>
    </bindings>
    

    Then when you define the endpoint:

    <endpoint address="" binding="netTcpBinding" bindingConfiguration="ExStreamWCFBinding" contract="ExStreamWCF.IService1"> 
    

    EDITED TO ADD

    Baed on your additional information, assing the bindingConfiguration attribute the value "NetTcpBinding_IService1" on the endpoint in your service.

    0 讨论(0)
  • 2020-11-27 22:00

    Sometimes changing "maxStringContentLength" value to maximum may not help.hence Add the below "default" binding inside the "basicHttpBinding" section in server config file.

              <binding >
                <readerQuotas maxDepth="32" maxStringContentLength="102400" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
              </binding>
    
    0 讨论(0)
提交回复
热议问题