【问题标题】:WCF : How to Set MaxReceivedMessageSize QuotaWCF:如何设置 MaxReceivedMessageSize 配额
【发布时间】:2011-12-10 00:01:33
【问题描述】:

我有一个 WCF 服务。运行客户端应用程序时收到以下消息

传入邮件的最大邮件大小配额 (65536) 已达到 超过。要增加配额,请使用 MaxReceivedMessageSize 相应绑定元素上的属性。

我还在客户端和服务器项目的相关配置中添加了 MaxReceivedMessageSize 属性。

我在客户端应用程序中的配置是:

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="RPBasicHttpBinding" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000">
          <readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:40003/PersonWcfService.svc/PersonServices"
        binding="basicHttpBinding"
        contract="RP.Common.ServiceContract.IPersonService" name="BasicHttpBinding_IPersonService">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>

我在 WCF 项目中的配置是:

<system.serviceModel>
    <services>
      <service name="RP.WcfService.PersonWcfService" behaviorConfiguration="RP.WcfServiceBehaviour">
        <endpoint address="PersonServices" binding="basicHttpBinding" bindingConfiguration="RPBasicHttpEndpointBinding" contract="RP.Common.ServiceContract.IPersonService" />
      </service>
    </services>
    <behaviors>
    <serviceBehaviors>
      <behavior name="RP.WcfServiceBehaviour">
        <serviceMetadata httpGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="true" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
    <bindings>
      <basicHttpBinding>
        <binding name="RPBasicHttpEndpointBinding" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000">
          <readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/>
        </binding>
      </basicHttpBinding>
    </bindings>
  </system.serviceModel>

那么我应该在哪里设置 MaxReceivedMessageSize 属性来增加消息大小配额?

【问题讨论】:

    标签: .net asp.net wcf .net-4.0 asp.net-4.0


    【解决方案1】:

    您是不是在客户端的端点配置中缺少 bindingConfiguration="RPBasicHttpBinding"... 从而获得了 basicHttpBinding 的默认配置而不是您指定的配置?

    【讨论】:

    • +1 谢谢!我的问题通过在端点配置中添加 bindingConfiguration="RCISPBasicHttpBinding" 解决。
    【解决方案2】:

    一旦您更改了服务器和消费者的配置,请确保重新启动这些进程(重新启动服务、重新启动应用程序池...等)。

    我也建议你不要在 localhost 下运行。 Localhost 可以绕过很多设置,从而使问题解决变得困难。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-07
      • 2013-01-15
      • 2010-11-23
      • 2015-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多