Receive large object with WCF

316 Views Asked by At

I have tried to receive a large object with XML over WCF. It doesn't work if I set maxStringContentLength={Default value}.

It only works when I increase maxStringContentLength but it decreases the performance.

Is there any solution to this issue without increasing maxStringContentLength?

2

There are 2 best solutions below

1
On

The short answer is no (for buffered messages). If you need to receive large string data, you need to increase the reader quotas. You should set them appropriately according to the maximum amount of data you want to allow.

3
On

This is a code smell for most WCF environments. If you are sending a large lump of XML that usually means that you aren't using a DataContract to send objects.

You've also noted that you want to use streaming. If this is the case then the reader quota's shouldn't come into play because what you are passing is a stream that will contain your data without a data contract at all.

If you are using buffers, then you can increase the size of your ReaderQuotas but this comes at the penalty of memory. Remember that these buffers are established for each incoming WCF call that you can process concurrently, so you could get into trouble.