2011-10-18 169 views
1

我有一个WCF服务。我运行客户端应用程序时收到以下消息WCF:如何设置MaxReceivedMessageSize配额

传入消息(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属性增加邮件大小配额?

回答

2

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

+0

+1没有看到,可能是这个问题 –

+0

+1谢谢!我的问题通过在端点配置中添加'bindingConfiguration =“RCISPBasicHttpBinding”'解决。 – Ehsan

1

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

我也建议你不要在localhost下运行。本地主机可以绕过许多设置,并且可以使问题解决变得困难。

相关问题