WCF:如何设置MaxReceivedMessageSize配额配额、如何设置、WCF、MaxReceivedMessageSize

2023-09-07 09:19:39 作者:つ铅笔画不出未来つ

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

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

的最大邮件大小配额传入消息(65536)已   超标。为了增加配额,使用MaxReceivedMessageSize   财产适当的绑定元素。

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.

此外,我加入MaxReceivedMessageSize财产相关的配置在客户端和服务器项目。

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>

我在WCF项目配置为:

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>

当其他的话,我应该设置MaxReceivedMessageSize属性增加邮件大小配额?

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

推荐答案

你是不是在客户端的端点配置中缺少 bindingConfiguration =RPBasicHttpBinding .. ,从而让您的指定配置的basicHttpBinding的的默认配置呢?

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?