1
votes

The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.

My section in the configuration file

  <system.serviceModel>
    <services>
      <service name="RestAPI.RiskEventAPI" behaviorConfiguration="metadataBehavior">
        <endpoint address=""
                  binding="basicHttpBinding"
                  contract="RestAPI.IRiskEventAPI"/>
        <endpoint address="mex"
                  binding="mexHttpBinding"
                  contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="metadataBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
        <behavior name="RestAPI.RiskEventAPIBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="REST">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <bindings>
      <webHttpBinding>
        <binding name="BindingWithMaxSizeIncreased"
                 maxBufferSize="2147483647"
                 maxBufferPoolSize="2147483647"
                 maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="2147483647" 
                        maxStringContentLength="2147483647"
                        maxArrayLength="2147483647" 
                        maxBytesPerRead="2147483647"
                        maxNameTableCharCount="2147483647" />
        </binding>
      </webHttpBinding>
    </bindings>
  </system.serviceModel>

it's confusing with the web going all over the place and nothing specific to REST and WCF. the debug window comes up but I get the error at the top of this question...

this didn't affect anything:

<endpoint address=""
          binding="basicHttpBinding"
          bindingConfiguration="BindingWithMaxSizeIncreased"
          contract="RestAPI.IRiskEventAPI"/>

copying

<webHttpBinding> to <basicHttpBinding> didn't help either

I tried this...i used the wcf editor and added a mexHttpBinding but it has issues with maxBufferSize, maxBufferPoolSize and maxReceivedMessageSize (says they're not allowed)

<mexHttpBinding>
    <binding name="bindingMex"
             maxBufferSize="2147483647"
             maxBufferPoolSize="2147483647" 
             maxReceivedMessageSize="2147483647"/>
  </mexHttpBinding>

i tried this (didn't work either):

    <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="IncreasedBindingMaxSize" contract="IMetadataExchange" />
...
      <basicHttpBinding>
        <binding name="IncreasedBindingMaxSize" maxBufferSize="2147483647"
          maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        </binding>
      </basicHttpBinding>
1
This is happening when debugging your service in visual studio itself, or when you attach to a running instance of your service? I've had cases before where I didn't update the config at the deployment location and I kept looking over the values in my visual studio project, not realizing that wasn't where it was wrong. If attaching, can you make sure you have updated your config in your deployment location? - Zack
great question - the client config is using https and is working ok it's just in debug mode in visual studio where we're getting this limit...since it's client specific (machine names, connection strings, etc.) I can't post it here... - rod
It seems you are confusing rest and wcf. rest utilizes http protocols while wcf uses SOAP. Or am I missing something here? - Shai Cohen
no we're good - we are in debug mode in visual studio and it is throwing the error whilst rest does not...so my question is how to configure debug mode to alleviate the error. when you have a small resultset (say < 65536) it returns JSON correctly in debug mode. when you have > 65536 bytes it throws this error. - rod

1 Answers

0
votes

I think the reason you're running into this issue is because you don't appear to have an explicitly defined endpoint for the webHttp, and you're not using default bindings in the configuration (i.e., a <binding> element with no name attribute).

This means that the system will use the default (smaller) values for the webHttpBinding. It's not clear if you're wanting to do both SOAP and REST endpoints for your service - you have an explicitly defined endpoint using basicHttpBinding that appears to be geared towards SOAP, but I'm not sure.

What you can do is change your service endpoint and use webHttpBinding, the REST behavior and explicitly assign your larger binding configuration "BindingWithMaxSizeIncreased" to that endpoint via the bindingConfiguration attribute on the <endpoint> element in the ` section, like this:

<endpoint address=""
          behaviorConfiguration="REST"
          binding="webHttpBinding"
          bindingConfiguration="BindingWithMaxSizeIncreased"
          contract="RestAPI.IRiskEventAPI"/>

If you do need the basicHttpBinding endpoint, you can add another endpoint with the webHttpBinding, though you may need an address different than address="", maybe something like address="REST".