WCF : How to Set MaxReceivedMessageSize Quota

核能气质少年 提交于 2019-12-24 11:29:45

问题


I have a WCF Service. I get the following message when I run the client application

The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.

Also i added MaxReceivedMessageSize property in related config in client and server projects.

My config in client application is :

<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>

My config in WCF project is :

<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>

Where other is then i should set MaxReceivedMessageSize property to increase message size quota?


回答1:


Aren't you missing bindingConfiguration="RPBasicHttpBinding" in your endpoint configuration on the client side... and thus getting a default configuration of the basicHttpBinding instead of your specified configuration?




回答2:


Once you have changed the config for the server and consumers, make sure you restart those processes(restart services, restart app pools....etc).

I also suggest you not run under localhost. Localhost gets to bypass lots of settings and can make problem solving difficult.



来源:https://stackoverflow.com/questions/7806056/wcf-how-to-set-maxreceivedmessagesize-quota

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!