开发者

Sending larger object to WCF results in 400 Bad Request

I have a unit test that sends a moderately large object to a WCF service. If I pass null for that parameter, everything works fine. When I send a populated object, I get an HTTP 400 response.

WCF tracing shows this error:

The maximum message size quota for incoming messages (65536) has been exceeded.

However, I have cranked up the size configuration parameters in app.config for the unit test project as follows:

<basicHttpBinding>
    <binding name="BasicHttpBinding_IMyAppService" closeTimeout="00:01:00"
        openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
        allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
        maxBufferSize="200000000" maxBufferPoolSize="200000000" maxReceivedMessageSize="200000000"
        messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
        useDefaultWebProxy="true">
      <readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/>
        <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
                realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
        </security>
    </binding>
</basicHttpBinding>

What am I missing in my configuration to raise the allowed message size above the 65536 seen in the error message?

UPDATE:

The web.config file for the web service host also sets the maxReceivedMessageSize to a large value (I think):

<binding name="basicHttpBindingConfig" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000">
  <readerQuotas maxDepth="32" maxAr开发者_如何学GorayLength="200000000" maxStringContentLength="200000000"/>
  <security mode="TransportCredentialOnly">
    <transport clientCredentialType="Ntlm"/>
  </security>
</binding>


If I understand your question correctly, you increased the size for 'maxReceivedMessageSize' in the unit test's app.config. Actually you should make this change in the app.config/web.config of the web service which you are calling from your unit test code. If you host your web service in IIS, then it will be web.config. If you host it in windows service, then you need to make the change in the app.config (which gets moved to your .exe.config file in your bin folder.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜