Choosing a Message Size for Buffered Copies
Creating a copy of a message requires passing the "maximum buffer size" to CreateBufferedCopy. How big should I make this maximum buffer size?
In most cases, you can use Int.MaxValue and not worry about the buffer size. Specifying this buffer size is primarily useful when you haven’t previously given a bound to the maximum size of the message.
- If you received this message using a buffered transfer, then you should have already had a quota applied on the maximum size of the received message.
- If you received this message using a streamed transfer, then you may want to specify a buffer size if the quota for streaming is larger than the amount you're willing to buffer into memory.
- If you are creating this message from scratch to send it or for other reasons, then you probably don't want to specify a limit. However, if the message is being built up as the result of several user-driven operations, then you may want to checkpoint the message size during copies to make sure that a malicious user isn't trying to run you out of memory. A malicious user can still make you do a lot of wasted work in this case, but that probably just means that you should require authorization before letting someone tie up your resources.
Note that whatever value you pass for the maximum buffer size, the default implementation of CreateBufferedCopy uses the maximum possible values for all of the XML reader quotas. It is just the total size of the message in bytes that is being bounded here.
Next time: Optional Interfaces on Binding Elements
Comments
- Anonymous
April 03, 2007
How do I enable Kerberos authentication for my web service? Kerberos is a very good authentication protocol