I am calling my WCF Web service using jQuery $.ajax json POST.
One of the input parameters is very long - over 8000 bytes. The data in it is a comma-separated list of GUIDs, like this "78dace54-1eea-4b31-8a43-dcd01e172d14,ce485e64-e7c6-481c-a424-2624371180aa,ede4c606-f743-4e0a-a8cc-59bcffa7feda,f0a81ed1-80db-4f6d-92d7-2fc47759a409".
When that parameter is 8176 bytes long, the request succeeds. When it's 8213 (one more comma and GUID) - the request fails.
It fails from the browser and from Fiddler (HTTP debugging proxy).
I added this to the webservice config:
<configuration>
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="50000000" recursionLimit="50000"/>
</webServices>
</scripting>
</system.web.extensions>
That does not make any difference, the request still fails for input param over 8176 bytes long.
That input param maps into a String on the WCF side.
What am I missing? Thank you!
UPDATE, this solved my problem: Turns out that this setting controls the total JSON message length
<webServices>
<jsonSerialization maxJsonLength="50000000" recursionLimit="50000"/>
</webServices>
There is another setting that controls maximum length for individual parameters:
<bindings>
<webHttpBinding>
<binding name="Binding_Name" maxReceivedMessageSize="900000">
<readerQuotas maxDepth="32" maxStringContentLength="900000" maxBytesPerRead="900000" maxArrayLength="120000" maxNameTableCharCount="120000"/>
</binding>
</webHttpBinding>
</bindings>
Also, make sure to set this:
<system.web>
<httpRuntime maxRequestLength="900000"/>
Hope this takes care of some headaches out there!
The actual limit seems to be 8192 bytes.
You have to check your Web.config in the system.serviceModel tag :
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="Service1Soap" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
You need to change maxStringContentLength="8192" to a greater value.
You may also make multiple requests instead of one to get the list of GUID page by page, using an offset parameter in each request. For example, to get list of GUID by pages of 200, first request with offset=0, second with offset=200, ... until you get less than 200 items.
I know it won't be of much help for you but I'd like to point out that the JSON spec does not set any limit; however, it allows parsers to do so:
An implementation may set limits on the size of texts that it
accepts. An implementation may set limits on the maximum depth of
nesting. An implementation may set limits on the range of numbers.
An implementation may set limits on the length and character contents of strings.
RFC4627: The application/json Media Type for JavaScript Object Notation (JSON)
See if this answer applies to you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With