2

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?

bobbymcr
  • 23,769
  • 3
  • 56
  • 67
aru
  • 21
  • 1
  • 2
    Have you looked at streaming? [Streaming Message Transfer](http://msdn.microsoft.com/en-us/library/ms731913.aspx) - if I remember correctly, you can also set a higher limit when streaming, and since it's not reading everything into the buffer first and then sending it should perform better. – Tim Oct 18 '11 at 05:35

2 Answers2

1

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.

bobbymcr
  • 23,769
  • 3
  • 56
  • 67
  • i am using transermode streamed but still need to set maxStringContentLength =819200.otherwise it produce error – aru Oct 18 '11 at 08:15
1

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.

Spence
  • 28,526
  • 15
  • 68
  • 103
  • i am using transermode streamed but still need to set maxStringContentLength =819200 but this useses penalty of memory .otherwise it produce error – aru Oct 18 '11 at 09:01
  • Unless you use a message contract to pass a stream, you will stream the data into a fixed size buffer, but your actual code wont trigger until you have the full message into your buffer. – Spence Oct 19 '11 at 02:08
  • Read this article on MSDN for more info about using a messageContract and passing streams via WCF. http://msdn.microsoft.com/en-us/library/ms733742.aspx – Spence Oct 19 '11 at 02:10