WCF - Increase ReaderQuoatas on REST service

1.9k views Asked by At

I have a WCF REST Service which accepts a JSON string

One of the parameters is a large string of numbers

This causes the following error - which is visible by tracing and using SVC Trace Viewer

There was an error deserializing the object of type CarConfiguration. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader.

Now I've read all sorts of articles advising how to rectify this

All of them recommend increasing various config settings on the server and client

e.g. Error Serializing String in WebService call

http://bloggingabout.net/blogs/ramon/archive/2008/08/20/wcf-and-large-messages.aspx

http://social.msdn.microsoft.com/Forums/en/wcf/thread/f570823a-8581-45ba-8b0b-ab0c7d7fcae1

So my config file looks like this

 <webHttpBinding>
        <binding name="webBinding" maxBufferSize="5242880"  maxReceivedMessageSize="5242880" >
          <readerQuotas  maxDepth="5242880" maxStringContentLength="5242880" maxArrayLength="5242880" maxBytesPerRead="5242880" maxNameTableCharCount="5242880"/>
        </binding>
   </webHttpBinding>
...
...
...
<endpoint 
      address="/"
      binding="webHttpBinding"
      bindingConfiguration="webBinding"

My problem is that I can change this on the server, but there are no WCF config settings on the client as its a REST service and I'm just making a http request using the WebClient object

any ideas?

2

There are 2 answers

0
ChrisCa On BEST ANSWER

so it turns out you need a fullly qualified url on the endpoint address, not a relative one

Error calling a WCF REST service using JSON. length quota (8192) exceeded

2
tomasr On

That error wouldn't be happening on the client, since reader quotas are a WCF-only thing and WebClient/HttpWebRequest don't do deserialization themselves or enforce any other kind of quotas.

So I'd say say that it's likely you're putting the configuration in the wrong place and it's not getting picked up.

Either that or... you're not using one of the WCF DataContract Serializers manually on the client side, are you?