I have a WCF service endpoint that serves binary documents through a stream. The endpoint looks something like this:
public Stream GetFile(int fileId){
...
}
The basicHttpBinding for this service endpoint is configured erroneously to use TransferMode="Buffered". The service endpoint is currently used by integrating parties outside my control. Due to the memory consumption issues with buffered transfermode I want to change this to TransferMode="Streamed".
Can I safely do this change on the service binding configuration and expect that this will not break anything for any integrating parties?
Windows Communication Foundation (WCF) transports support two modes for transferring messages: Buffered transfers hold the entire message in a memory buffer until the transfer is complete. A buffered message must be completely delivered before a receiver can read it.
Selecting between buffered and streamed transfer modes is done on the binding element of the transport. The binding element has a TransferMode property that can be set to Buffered, Streamed, StreamedRequest, or StreamedResponse. Setting the transfer mode to Streamed enables streaming communication in both directions.
Windows Communication Foundation (WCF) transports support two modes for transferring messages: Buffered transfers hold the entire message in a memory buffer until the transfer is complete. Streamed transfers expose the message as a stream.
Changing the transfer mode from buffered to streamed also changes the native channel shape of the TCP and named pipe transports. For buffered transfers, the native channel shape is IDuplexSessionChannel. For streamed transfers, the native channels are IRequestChannel and IReplyChannel.
To the best of my knowledge, WCF streamed mode transfer is opt-in at the client, meaning that even if you change it at the server, unless the client changes their end as well they'll still receive the stream in its entirety before serving it as a buffered chunk of data. In other words, it should be transparent to your clients, but will enable them to opt-in to a streamed response.
Official Microsoft documentation on the matter confirms it is opt-in and does NOT affect functionality meaning it should not be a breaking change.
"You can turn on streaming for requests and replies or for both directions independently at either side of the communicating parties without affecting functionality. However, you should always assume that the transferred data size is so significant that enabling streaming is justified on both endpoints of a communication link. For cross-platform communication where one of the endpoints is not implemented with WCF, the ability to use streaming depends on the platform's streaming capabilities."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With