在WCF中请求实体太大错误(413)

时间:2015-03-03 08:24:34

标签: c# .net wcf iis-7 wcf-binding

即使maxReceivedMessageSize设置为max(即2147483647且实际邮件大小小于50kb),我在WCF服务中也会遇到413错误。

只有在两个请求之间有理想的时间时才会出现此问题。 具体情况如下: 1.发送1000条消息,每条消息约为38 kb。状态:通过 2.等待一段时间(最少3分钟) 3.发送1条消息。状态:失败。 (413错误)

我正在使用ws2007FederationHttpBinding。 Web.config标记如下:

<ws2007FederationHttpBinding>
    <binding name="federationHttpBinding" openTimeout="00:04:00" closeTimeout="00:04:00" receiveTimeout="00:04:00" sendTimeout="00:40:00" maxReceivedMessageSize="2147483647">
      <!-- <readerQuotas maxArrayLength="2147483647" maxDepth="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647" /> -->
      <security mode="TransportWithMessageCredential">
        <message establishSecurityContext="false">
        </message>
      </security>
    </binding>
  </ws2007FederationHttpBinding>

客户端绑定标记如下:

<ws2007FederationHttpBinding>
    <binding name="AuthorizationBinding" openTimeout="00:04:00" closeTimeout="00:04:00" receiveTimeout="00:04:00" sendTimeout="00:40:00" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647">
      <readerQuotas maxArrayLength="2147483647" maxDepth="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" maxStringContentLength="2147483647"/>
      <security mode="TransportWithMessageCredential">
        <message establishSecurityContext="false"/>
      </security>
    </binding>
</ws2007FederationHttpBinding>

2 个答案:

答案 0 :(得分:0)

您还必须设置maxBufferSize

    <binding name="federationHttpBinding" 
             maxReceivedMessageSize="2147483647" 
             maxBufferSize="2147483647"
             maxBufferPoolSize="2147483647">

答案 1 :(得分:0)

我认为您可以通过从绑定标记中删除name属性来解决此问题,可以在此处找到类似的问题

WCF service maxReceivedMessageSize basicHttpBinding issue