Large Messages and WCF
CLR typed objects (and buffered messages) are great for a large breadth of applications. Sometimes though, you just want to push bytes. WCF provides a convenient way of doing so with “streamed methods”.
To use WCF’s “Streaming API” you write an operation with an input and/or output of type System.IO.Stream. Because the Stream parameter utilizes the entire body, if an input or an output (i.e. ref parameter, out parameter, or return value) is of type Stream then it must be the only input/output specified in your OperationContract.
When using a Streaming method, you need to pass in a Stream object that provides data incrementally from its Read() method. One common area of confusion is that your return Stream must also be written with the Read() method providing the data. The mental model is that the client is “reading” the return value, and not that the server is “writing” the result.
Now that your operation has been architected so that it no longer requires buffering, you have to choose a binding that is compatible with moving a lot of bytes around. Yasser wrote a nice post on this topic here. In a nutshell you need to:
May 6th, 2006 at 1:41 am
[…] […]
October 28th, 2006 at 8:55 pm
[…] When I talked about transferring large messages with WCF, I neglected to cover how security interacts with streamed messages. […]
December 11th, 2007 at 4:10 pm
[…] Wolf has a great post on the Streaming API of Indigo which is very useful for large […]