繁体   English   中英

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

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

我收到一个错误

超出最大字符串内容长度配额(8192)

我知道我需要修改WCF配置,但无法使其正常运行。 到目前为止,这是我所拥有的:我尝试使用内置的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是正确的关于绑定的再次是:

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

但是我也收到错误“超出最大字符串内容长度配额(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>

默认的maxStringContentLength设置为8192,我将其增加到65536,问题已解决。

您需要如下更改绑定部分:

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

您的端点指定它正在使用wsHttpBinding,但是您仅配置了basicHttpBinding。

这意味着您的服务将仅使用默认值

顺便说一句,您指定的那些值巨大,您可能需要查看这些值

-更新

在绑定中添加了maxReceivedMessageSize属性。

您也可以确认是否在客户端进行了任何更改。 基本上,客户端和服务器配置都应该匹配。

您正在设置正确的属性( maxStringContentLength ),但是绑定错误。 问题在于您正在为basicHttpBinding定义配置,但在服务端点上使用了wsHttpBinding 将绑定配置更改为wsHttpBinding ,它应该可以正常工作(您可能想验证是否需要通过wsHttpBinding提供的WS- *功能,也可以将端点的绑定更改为basicHttpBinding ,只要您不这样做也可以使用需要支持分布式交易等)

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM