Search This Blog

Thursday, February 28, 2013

"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."

This happened when I was sending large chunks of data through a WCF service -- by default it seems that the service is configured not accept anything over a certain size, probably as a security measure.

Overriding it is done by adding a "readerQuotas" section:

<bindings>
  <basicHttpBinding>
    <binding maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
  </basicHttpBinding>
</bindings>

Drawn from this blog:

http://www.megustaulises.com/2012/04/wcf-common-error-messages-tips-and.html?_escaped_fragment_="

A word of caution, though -- in most examples I found in Google there was an admonition to add a "name" attribute to the "binding" element (e.g., http://stackoverflow.com/questions/3068076/wcf-service-the-maximum-array-length-quota-16384-has-been-exceeded) and if you use the "Edit WCF Configuration" utility in Visual Studio 2010 it'll actually say there's an error when it senses that the "name" attribute is missing.

This has confused more people than just me -- see https://go4answers.webhost4life.com/Example/maximum-array-length-quota-16384-36456.aspx, especially "Answer 6".  It seems that if the "name" attribute is left out then the change is made to the global binding definition if the WCF project is .NET 4.0+.

The confusion would seem to come from an improvement in the structure of WCF config files introduced in .NET 4.0/4.5 as a "simplification" feature, documented in http://msdn.microsoft.com/en-us/library/hh309266.aspx

Tuesday, February 26, 2013

WCF Error: "This collection already contains an address with scheme http"

This comes when pushing a new WCF service up from development to production -- it'll work fine in dev, then fail with this message in production:

"This collection already contains an address with scheme http"

The solution is to update the web.config section of the IIS hosted WCF service and the app.config section of the library used by WCF and is described in a couple different links:





In my case, I put this code right after the <servicemodel> tag:

<servicemodel>
  <serviceHostingEnvironment>
    <baseAddressPrefixFilters>
        <add prefix=http://mignysm95bakpv.nysemail.nyenet"/>
    <baseAddressPrefixFilters>
  </serviceHostingEnvironment>
....
etc. etc. etc. ....
</servicemodel>





I wish I knew WCF well enough to say what the fix is actually doing but at present I can't quite say what's going on -- I'm still learning it and, once I find out what my problem is, I'll add to this post.  In the meantime, I've just got to get this running.