0

I get this error message

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

when I try to upload files(+-160KB) to my WCF service. I've tried to increase the values of the following attributes :

maxReceivedMessageSize,
maxBufferPoolSize,
maxArrayLength,
maxStringContentLength, 

but I had no luck. My WCF config file looks like this :

<system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="wsBinding" maxReceivedMessageSize="3200000" maxBufferPoolSize="100000000"  >
          <readerQuotas maxArrayLength="1000000000" maxStringContentLength="3200000" />
        </binding>
      </wsHttpBinding>
    </bindings>
    <client />
    <services>
      <service behaviorConfiguration="PMSService.Thomolosha"
        name="PMSService.Thomolosha" >
        <endpoint address="" binding="wsHttpBinding"  contract="PMSService.ThomoloshaDeclaration">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding"  contract="IMetadataExchange" />
      </service>
      <service behaviorConfiguration="PMSService.Arekwe"
              name="PMSService.Arekwe">
        <endpoint address="" binding="wsHttpBinding" contract="PMSService.ArekweDeclaration">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="PMSService.Thomolosha">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
        <behavior name="PMSService.Arekwe">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

My Winform config looks like this :

<system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_ThomoloshaDeclaration" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
          maxBufferPoolSize="100000000" maxReceivedMessageSize="3200000" messageEncoding="Text"
          textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="3200000" maxArrayLength="1000000000"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00"
            enabled="false" />
          <security mode="Message">
            <transport clientCredentialType="Windows" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="Windows" negotiateServiceCredential="true"
              algorithmSuite="Default" />
          </security>
        </binding>
        <binding name="WSHttpBinding_ArekweDeclaration" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
          maxBufferPoolSize="100000000" maxReceivedMessageSize="3200000" messageEncoding="Text"
          textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="3200000" maxArrayLength="1000000000"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00"
            enabled="false" />
          <security mode="Message">
            <transport clientCredentialType="Windows" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="Windows" negotiateServiceCredential="true"
              algorithmSuite="Default" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:57388/Thomolosha.svc" binding="wsHttpBinding"
        bindingConfiguration="WSHttpBinding_ThomoloshaDeclaration" contract="Thomolosha.ThomoloshaDeclaration"
        name="WSHttpBinding_ThomoloshaDeclaration">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
      <endpoint address="http://localhost:57388/Arekwe.svc" binding="wsHttpBinding"
        bindingConfiguration="WSHttpBinding_ArekweDeclaration" contract="Arekwe.ArekweDeclaration"
        name="WSHttpBinding_ArekweDeclaration">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
chosenOne Thabs
  • 1,480
  • 3
  • 21
  • 39
  • possible duplicate of [The maximum message size quota for incoming messages (65536) has been exceeded](http://stackoverflow.com/questions/5459697/the-maximum-message-size-quota-for-incoming-messages-65536-has-been-exceeded) – Garrett Vlieger Jul 22 '14 at 19:44
  • In the code are you sure you're using the correct binding? – Aelphaeis Jul 22 '14 at 19:44
  • @GarrettVlieger duplicate how ? – chosenOne Thabs Jul 22 '14 at 19:50
  • @Aelphaeis yes, it works fine with small files. – chosenOne Thabs Jul 22 '14 at 19:51
  • @chosenOneThabs, this is the same question as one that's already been answered. Follow the link to see a possible solution to your problem. – Garrett Vlieger Jul 22 '14 at 19:52
  • @GarrettVlieger yes i have tried most of those solutions but no luck. Most people suspect these attributes : maxReceivedMessageSize, maxBufferPoolSize,maxArrayLength,maxStringContentLength. I've fiddle around with these attributes but i had no luck. That's why i decided to paste my configs in this block. – chosenOne Thabs Jul 22 '14 at 19:57
  • @chosenOneThabs if you follow the 'possible duplicate of' questions all the way back you'll find [this answer](http://stackoverflow.com/a/9018218/97614) which shows the named config being applied. – Sam Holder Jul 22 '14 at 21:22
  • possible duplicate of [WCF - How to Increase Message Size Quota](http://stackoverflow.com/questions/884235/wcf-how-to-increase-message-size-quota) – Sam Holder Jul 22 '14 at 21:22

1 Answers1

3

It sounds like you're getting the error on the service side (when you try to upload). According to your posted service config, you've set a higher limit for maxReceivedMessageSize and other settings, but you never assign that binding to your service endpoint(s), so WCF is using the default value for maxReceivedMessageSize (65536).

You need to assign your defined binding (wsBinding) to your service endpoint(s) via the bindingConfiguration attribute of the endpoint element, like this:

<endpoint address="" 
          binding="wsHttpBinding"
          bindingCongifuration="wsBinding"
          contract="PMSService.ThomoloshaDeclaration">

Now the service will use the binding configuration you've defined, that has the larger size.

Tim
  • 28,212
  • 8
  • 63
  • 76
  • @chosenOneThabs: If this answer did solve your problem as you have indicated, then please mark it as such. This may help guide programmers to the answer in the future when trying to solve this problem. – Derek W Jul 23 '14 at 22:53