CustomBinding with reliableSession Vs basicHttpBinding,传入消息(65536)已超出错误

时间:2014-04-30 13:58:16

标签: .net wcf

我在Windows Server 2008上有一个由IIS 7托管的WCF服务。

我需要支持WCF服务的不同配置。

当我尝试批量插入600行4个整数的DataTabale时,我遇到了问题。

一个配置是 CustomBinding with reliableSession

客户:

<customBinding>
    <binding name="reliableSessionOverHttps" receiveTimeout="00:02:00" sendTimeout="00:02:00" openTimeout="00:02:00" closeTimeout="00:02:00">
      <reliableSession inactivityTimeout="00:10:00" flowControlEnabled="true" maxTransferWindowSize="4096" maxPendingChannels="4" ordered="true" maxRetryCount="4" reliableMessagingVersion="Default" acknowledgementInterval="00:10:00"/>
      <httpsTransport maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" manualAddressing="false" allowCookies="false" authenticationScheme="Anonymous" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" keepAliveEnabled="true" proxyAuthenticationScheme="Anonymous" realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false" useDefaultWebProxy="true"/>
    </binding>
  </customBinding>

我的服务器配置:

<customBinding>
    <binding name="reliableSessionOverHttps" receiveTimeout="00:01:00"
           sendTimeout="00:01:00"
           openTimeout="00:01:00"
           closeTimeout="00:05:00">
      <reliableSession />
      <httpsTransport maxReceivedMessageSize="2147483647"/>
    </binding>
  </customBinding>

一切正常。

但是当我使用 basicHttpBinding 时,我得到:&#34;已超出传入消息的最大邮件大小配额(65536)。要增加配额,请在相应的绑定元素上使用MaxReceivedMessageSize属性&#34;。

客户端:

<basicHttpBinding>
    <binding name="basicHttpBindNoCert" receiveTimeout="00:02:00" sendTimeout="00:02:00" openTimeout="00:02:00" closeTimeout="00:02:00"  
       maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647"  allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"  transferMode="Buffered" useDefaultWebProxy="true">
    </binding>
  </basicHttpBinding>

服务器

<basicHttpBinding>
    <binding name="secureHttpBinding" receiveTimeout="00:01:00"
           sendTimeout="00:01:00"
           openTimeout="00:01:00"
           closeTimeout="00:05:00" maxReceivedMessageSize="2147483647">
    </binding>
  </basicHttpBinding>

我收到了有关此配置的错误。

知道为什么吗?以及如何解决? (我知道我可以用更小的批量发送它)

1 个答案:

答案 0 :(得分:0)

您还必须增加maxBufferSize服务器端。它必须与maxReceivedMessageSize相同。您还应该将尺寸减小到更合理的尺寸。 2GB很大,只会使用资源或使您容易受到攻击。使用2MB:2097152。