views:

98

answers:

2

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. http://stackoverflow.com/questions/65452/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?

A: 

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?

tomasr
Definitely putting the settings in the correct Binding as have made a deliberate typo in the endpoint and seen it fail. Kind of agree with you regarding it not being necessary on the client but so many articles say it has to be in both. Obviously there is no such settings on a rest client
Christo Fur
Beats me then. What's the right address for the endpoint you're configuring?
tomasr
A: 

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

http://stackoverflow.com/questions/2257808/error-calling-a-wcf-rest-service-using-json-length-quota-8192-exceeded

Christo Fur