The maximum message size quota for incoming messages (65536) has been exceeded
Asked Answered
E

2

7

My WCF Service has an OperationContract that accepts, as a parameter, an array of objects. This can potentially be quite large. After looking for fixes for Bad Request: 400, I found the real reason: the maximum message size.

I know this question has been asked before in MANY places. I've tried what everyone says: "Increase the sizes in the client and server config files." I have. It still doesn't work.

My Service's web.config:

<system.serviceModel>
    <services>
      <service name="myService">
        <endpoint name="myEndpoint" address=""
                  binding="basicHttpBinding"
                  bindingConfiguration="myBinding"
                  contract="Meisel.WCF.PDFDocs.IPDFDocsService" />
      </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding name="myBinding"
                 closeTimeout="00:11:00"
                 openTimeout="00:11:00"
                 receiveTimeout="00:15:00"
                 sendTimeout="00:15:00"
                 maxBufferSize="2147483647"
                 maxReceivedMessageSize="2147483647"
                 maxBufferPoolSize="2147483647"
                 transferMode="Buffered"
                 allowCookies="false"
                 bypassProxyOnLocal="false"
                 hostNameComparisonMode="StrongWildcard"
                 messageEncoding="Text"
                 textEncoding="utf-8"
                 useDefaultWebProxy="true">
          <readerQuotas maxDepth="2147483647"
                        maxStringContentLength="2147483647"
                        maxArrayLength="2147483647"
                        maxBytesPerRead="2147483647"
                        maxNameTableCharCount="2147483647" />
          <security mode="None" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

My Client's app.config:

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IPDFDocsService"
                 closeTimeout="00:11:00"
                 openTimeout="00:11:00"
                 receiveTimeout="00:10:00"
                 sendTimeout="00:11:00"
                 allowCookies="false"
                 bypassProxyOnLocal="false"
                 hostNameComparisonMode="StrongWildcard"
                 maxBufferSize="2147483647"
                 maxBufferPoolSize="2147483647"
                 maxReceivedMessageSize="2147483647"
                 messageEncoding="Text"
                 textEncoding="utf-8"
                 transferMode="Buffered"
                 useDefaultWebProxy="true">
          <readerQuotas maxDepth="32"
                        maxStringContentLength="2147483647"
                        maxArrayLength="2147483647"
                        maxBytesPerRead="2147483647"
                        maxNameTableCharCount="2147483647" />
          <security mode="None">
            <transport clientCredentialType="None"
                       proxyCredentialType="None"
                       realm="" />
            <message clientCredentialType="UserName"
                     algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:8451/PDFDocsService.svc"
                behaviorConfiguration="MoreItemsInObjectGraph"
                binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_IPDFDocsService"
                contract="PDFDocsService.IPDFDocsService"
                name="BasicHttpBinding_IPDFDocsService" />
    </client>
    <behaviors>
      <endpointBehaviors>
        <behavior name="MoreItemsInObjectGraph">
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>

What can I possibly be missing or doing wrong? It's as though the service is ignoring what I typed in the maxReceivedBufferSize.

Thanks in advance, Kyle

UPDATE

Here are two other StackOverflow questions where they never received an answer, either:

https://stackoverflow.com/questions/2880623/maxreceivedmessagesize-adjusted-but-still-getting-the-quotaexceedexception-with

WCF MaxReceivedMessageSize property not taking

Elbert answered 25/5, 2010 at 22:2 Comment(3)
It looks correct at a glance. Are you configuring the end point in the code anywhere? If so, that might be overriding the config settings.Panthia
How are you hosting the service? IIS?Subkingdom
@Jeff: I'm just creating a new instance of my Service Client, then calling the OperationContract, passing in my custom class as a parameter. Nothing fancy. @Simon: I'm using the ASP .NET Development Server. Currently, it's all local.Elbert
S
7

In the service config file, the "name" attribute is missing from the element

<behaviors>
  <serviceBehaviors>
    <behavior name="StackOverflow">

and there should be a reference to this name in the service element:

<system.serviceModel>
    <services>
        <service behaviorConfiguration="StackOverflow" name="myService">
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="myBinding"

In general, it's a good idea to validate, if not always edit, your WCF config files using the "WCF Service Configuration Editor", which is invoked from the Visual Studio "Tools" menu item.

Also there is no endpoint behavior defined for the service. I don't know if this matters.

Subkingdom answered 26/5, 2010 at 1:1 Comment(2)
Would you believe me if I told you that when I add a name to my behavior, the WCFTestClient gives me the error: "Error: Cannot obtain Metadata. Metadata contains a reference that cannot be resolved. Content Type application/soap+xml; charset=utf-8 was not supported by service. The client and service bindings may be mismatched. The remote server returned an error: (415) Unsupported Media Type.HTTP GET. The HTML document does not contain Web service discovery information." This is why I didn't include a name for my behavior.Elbert
I'm still not sure what the true solution was to this issue, but I was able to get my ORIGINAL problem resolved, making this issue moot. FWIW, it seems as though I was able to get rid of the above error by making SURE my service used behaviorConfiguration. Thanks!Elbert
O
0

I had the same problem with WCF Test and I had set corectly the config file. If isn't any problems from your config file, I suggest try to test the service with another program eg: SOAP UI, I think this error it's not from the service, it's from the WCF Test.

Orling answered 25/9, 2014 at 8:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.