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:
Pingback: mattonsoftware.com : .NET Resources
Pingback: kennyw.com » Blog Archive » Security and Streamed Messages
Pingback: New and Notable 92 - Sam Gentile