WCF webservice:发送大量输入时HTTP / 1.1 400 Bad Request

时间:2010-09-03 14:03:20

标签: wcf web-services soapui

我正在连接到基于WCF的Web服务。对于某些方法,输入包含对象/结构的列表。当此列表中的项目数增加超过一定数量时,当我尝试使用SOAPUI测试相同时,服务将失败并显示HTTP/1.1 400 Bad Request。我尝试使用以下更改来更改web.config文件:

<httpRuntime maxRequestLength="2097151" />

   <binding name="basicHTTP" closeTimeout="00:01:00"
        openTimeout="00:01:00" receiveTimeout="00:01:00" sendTimeout="00:01:00" maxReceivedMessageSize="4194304" maxBufferSize="98547" maxBufferPoolSize="258547">
     <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
   </binding>

2 个答案:

答案 0 :(得分:3)

问题已由maxReceivedMessageSize设置解决。最初在我的绑定中,虽然bindingConfiguration已声明并设置,但我没有明确设置basicHttpBinding

由于绑定中的maxReceivedMessageSize中的此类更改未应用,并且默认设置为64kb处于活动状态。我已经设置了绑定:

<endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpBinding"
 name="AMS" bindingName="basicHttpBinding" contract="Entity.AccuchekMobility.Service.IAccuchekMobilityService" />

   <binding name="basicHttpBinding" closeTimeout="00:01:00"
        openTimeout="00:01:00" receiveTimeout="00:02:00" sendTimeout="00:01:00" maxReceivedMessageSize="4194304" maxBufferPoolSize="524288" maxBufferSize="4194304">

答案 1 :(得分:2)

请注意,maxReceivedMessageSize以字节为单位,而maxRequestLength以KiloBytes为单位。同样对于缓冲传输,将缓冲区大小设置为与最大消息大小相同的值。失败的输入有多大?