简体   繁体   English

WCF Config修复最大字符串内容长度配额(8192)

[英]WCF Config to fix The maximum string content length quota (8192) has been exceeded

I am getting a error 我收到一个错误

The maximum string content length quota (8192) has been exceeded 超出最大字符串内容长度配额(8192)

I know I need to modify my WCF configuration but I can't get it working. 我知道我需要修改WCF配置,但无法使其正常运行。 Here's what I have so far: I tried to use the buil-in WCF editor. 到目前为止,这是我所拥有的:我尝试使用内置的WCF编辑器。

    <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding>
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        </binding>
      </wsHttpBinding>
    </bindings>

    <client>
      <remove contract="IMetadataExchange" name="sb" />
      <endpoint address="" binding="netTcpRelayBinding" contract="IMetadataExchange"
        name="sb" />
    </client>
    <services>
      <service name="SvcLibrary.Service1">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8732/Design_Time_Addresses/SvcLibrary/Service1/"/>
          </baseAddresses>
        </host>
        <!-- Service Endpoints -->
        <!-- Unless fully qualified, address is relative to base address supplied above -->
        <endpoint address="" binding="wsHttpBinding" contract="SvcLibrary.IService1">
          <!-- 
              Upon deployment, the following identity element should be removed or replaced to reflect the 
              identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
              automatically.
          -->
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <!-- Metadata Endpoints -->
        <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
        <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="True"/>
          <!-- To receive exception details in faults for debugging purposes, 
          set the value below to true.  Set to false before deployment 
          to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="False"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

SCB is correct the regarding the bindings which again are: SCB是正确的关于绑定的再次是:

<bindings>
      <wsHttpBinding>
        <binding>
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        </binding>
      </wsHttpBinding>
    </bindings>

But I was also getting the error "The maximum string content length quota (8192) has been exceeded" because I needed to modify the client app as follows: 但是我也收到错误“超出最大字符串内容长度配额(8192)”,因为我需要按如下方式修改客户端应用程序:

 <basicHttpBinding>
        <binding name="BasicHttpBinding_IXRMService" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
          maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
          useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="65536" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>

The default maxStringContentLength was set to 8192 I increased it to 65536 and the problem is solved 默认的maxStringContentLength设置为8192,我将其增加到65536,问题已解决。

You need to change your binding section as follows: 您需要如下更改绑定部分:

<bindings>
      <wsHttpBinding>
        <binding maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        </binding>
      </wsHttpBinding>
    </bindings>

Your endpoint specifies that it is using the wsHttpBinding but you have only configured the basicHttpBinding. 您的端点指定它正在使用wsHttpBinding,但是您仅配置了basicHttpBinding。

This means that your service will only be using the defaults 这意味着您的服务将仅使用默认值

By the way those values you have specified are huge, you might want to review those 顺便说一句,您指定的那些值巨大,您可能需要查看这些值

-- Update -更新

Added a maxReceivedMessageSize attribute to the binding. 在绑定中添加了maxReceivedMessageSize属性。

Also can you confirm if you have made any changes on the client side. 您也可以确认是否在客户端进行了任何更改。 Basically both the client and the server configurations should match. 基本上,客户端和服务器配置都应该匹配。

You're setting the right property ( maxStringContentLength ) but on the wrong binding. 您正在设置正确的属性( maxStringContentLength ),但是绑定错误。 The problem is that you're defining the configuration for basicHttpBinding but using wsHttpBinding on your service endpoint. 问题在于您正在为basicHttpBinding定义配置,但在服务端点上使用了wsHttpBinding Change your binding configuration to wsHttpBinding and it should work fine (you might want to verify whether you need the WS-* capabilities offered through wsHttpBinding , you could also change your endpoint's binding to basicHttpBinding and that would work too, as long as you don't need support for distributed transactions, etc.) 将绑定配置更改为wsHttpBinding ,它应该可以正常工作(您可能想验证是否需要通过wsHttpBinding提供的WS- *功能,也可以将端点的绑定更改为basicHttpBinding ,只要您不这样做也可以使用需要支持分布式交易等)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 WCF-读取XML数据时超出了最大字符串内容长度配额(8192) - WCF - The maximum string content length quota (8192) has been exceeded while reading XML data 将 XML 字符串发送到 WCF 时出现“读取 XML 数据时已超出最大字符串内容长度配额 (8192)”错误 - "The maximum string content length quota (8192) has been exceeded while reading XML data" error while sending XML string to WCF “在读取XML数据时已超出最大字符串内容长度配额(8192)”将XML字符串发送到WCF时出错 - “The maximum string content length quota (8192) has been exceeded while reading XML data” error while sending XML string to WCF 已超过最大字符串内容长度配额(8192)。增加XmlDictionaryReaderQuotas的MaxStringContentLength属性 - The maximum string content length quota (8192) has been exceeded.Increase the MaxStringContentLength property on the XmlDictionaryReaderQuotas 反序列化类型的对象时发生错误...读取XML数据时超出了最大字符串内容长度配额(8192) - There was an error deserializing the object of type … The maximum string content length quota (8192) has been exceeded while reading XML data WCF阅读器配额最大字符串内容长度配额(8192) - WCF reader quota The maximum string content length quota (8192) 使用Delphi使用WCF - 最大字符串内容长度配额(8192)错误 - Consuming WCF with Delphi - Maximum string content length quota (8192) error WCF:读取XML数据时已超出最大数组长度配额(16384) - WCF: The maximum array length quota (16384) has been exceeded while reading XML data C#WCF最大字符串内容长度配额 - c# WCF maximum string content length quota 已处理ProtocolException,最大字符串内容长度配额8192 - ProtocolException was handled, Max string content length quota 8192
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM