1

Based on this post Error calling a WCF REST service using JSON. length quota (8192) exceeded

I experienced the same problem when calling my WCF REST Service (hosted on IIS 7) from a console application (using Microsoft.HttpClient library). I have increased the maxStringContentLength="2147483647" on the WCF REST Service config, but it still throws the same error for files bigger than 8KB. (Note: there is no client configuration as I simply make a HTTP Post request, I got the same problem when test it using Fiddler)

This is my WCF REST config

<system.serviceModel>
<bindings>
  <webHttpBinding>
    <binding name="webBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
      <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
    </binding>
  </webHttpBinding>
</bindings>
<services>
  <service behaviorConfiguration="ServiceBehavior" name="EmailService">
    <host>
      <baseAddresses>
        <add baseAddress="http://mywebsite.com/v1" />
      </baseAddresses>
    </host>
    <endpoint address="" binding="webHttpBinding" bindingConfiguration="webBinding" behaviorConfiguration="webBehavior" contract="IEmailService" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="webBehavior">
      <webHttp/>
    </behavior>
  </endpointBehaviors>
</behaviors>

Community
  • 1
  • 1
chris soe
  • 21
  • 3
  • This question has been asked dozens of times. http://stackoverflow.com/search?q=maxStringContentLength – Darrel Miller Sep 15 '10 at 14:38
  • I did increase the maxStringContentLength in my server configuration like most people did, but it still throws the error when submitting post data larger than 8KB to my WCF REST Service (its REST based API that uses HTTP communication). Since putting bigger numbers on server config doesn't change anything, I'm thinking to re-implement ServiceHostFactory and do all the bindings programmatically, but I'm not sure how it will make any difference than modifying the config. – chris soe Sep 15 '10 at 15:23
  • What version of .NET Framework / WCF do you use? – Ladislav Mrnka Sep 15 '10 at 18:51
  • .NET 3.5, WCF hosted on IIS 7, the client is just a console app that uses HttpClient to make HTTP POST/GET request with a content formatted as JSON – chris soe Sep 16 '10 at 02:21
  • At this point, I would add a trace listener and verify nothing else is going wrong. It's been a while since I had to do this, maybe this is helpful http://stackoverflow.com/questions/4004160/adding-tracelistener-to-web-config . Also, is this from sending files via a file upload control, or some other method. – Mike C. Feb 18 '13 at 13:33

1 Answers1

-1

hey it seem that you are sending more data then it is allowed i.e int.max length, try using custom binding (Binary ) that will help you

Singleton
  • 3,701
  • 3
  • 24
  • 37