2

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" maxArrayLength="200000000" maxStringContentLength="200000000"/>
  <security mode="TransportCredentialOnly">
    <transport clientCredentialType="Ntlm"/>
  </security>
</binding>
Eric J.
  • 147,927
  • 63
  • 340
  • 553

1 Answers1

1

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.

KrishHari
  • 449
  • 5
  • 10
  • Sorry, I left that part out of my original question. I also set the maxReceivedMessageSize in the web service's web.config. Question is updated with the specific configuration. Do you see a problem there? – Eric J. Sep 23 '11 at 07:26
  • Where do you host the web service? If it is hosted in windows service, check the appname.exe.config(where appname is your application name) for the configuration settings. The config file will usually updated automatically when you recompile. – KrishHari Sep 23 '11 at 15:18
  • Right now, it's hosted in a website project in VS 2010. There is a web.config for that project (relevant part is now posted in the question) – Eric J. Sep 23 '11 at 15:42
  • I think your answer is pretty complete given the original problem, so I'm going to accept it. I discovered more but will open a new question for that. Thanks! – Eric J. Sep 24 '11 at 02:03