0

I have a WCF service implemented using the WebServiceHostFactory (REST).

I'm calling a service end point as a POST sending a json object that has a string property.

This works up to a point but it seems that if the length of that string gets too long (not sure exactly how long (8000 chars works but 9000 does not ... I did not try but 'breaking point' might be 8192).

I attempt to check the StatusCode in the call back which works fine for smaller strings but when the sting is 'too long' the code below errors with:

System.Net.WebException: The remote server returned an error: NotFound.

Callback code:

var request = (HttpWebRequest)result.AsyncState;
var response = (HttpWebResponse)request.EndGetResponse(result);

I'm trying to figure out where the problem is, since the service exists and I only get this when the string is too long.

Is it the json object size? Is it my service definition? Is this something in WCF?

Thanks

2 Answers 2

1

I think that it is problem with MaxStringContentLength property from reader quotas. Its default value is indeed 8192. You can change the value in binding configuration:

<system.serviceModel>
  <bindings>
    <webHttpBinding>
      <binding name="LargeString">
        <readerQuotas maxStringContentLength="16000" />
      </binding>
    </webHttpBinding>
  </bindings>
</system.serviceModel>

Reference this binding configuration in your endpoint configuration:

  <endpoint address="..." contract="..." binding="webHttpBinding" bindingConfiguration="LargeString" />

In case of WCF 4.0 you can omit name in binding definition and it should be used as default configuration for all webHttp endpoints.

Sign up to request clarification or add additional context in comments.

Comments

0

I can think of a reasons without knowing it. Maybe you exceed the maximum message length? This can be set in your App.Config file.

If you have a vast amount of data to transfer you could either use streaming or build your own API just like cursors work in SQL.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.