16

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?

Andreas Presthammer
  • 1,886
  • 2
  • 19
  • 31
  • In a .NET <-> .NET scenario it doesn't matter if TransferMode differ between client and server. – Jon Lindeheim May 15 '14 at 07:12
  • We may have ANY client, although it would typically be Java or .Net. – Andreas Presthammer May 15 '14 at 08:01
  • I am not confident enough to post as an answer, but I think it is a breaking change. This is only because I know I have had issues where my client would not work because I forgot to set it to streamed. – Scott Chamberlain May 18 '14 at 18:48
  • this isn't really an answer but isn't it something that can easily be tested? Or is already tested through some load tests? – John Nicholas May 19 '14 at 10:10
  • I've verified that a .net client doesnt break. Have no idea any other client could break though... – Andreas Presthammer May 19 '14 at 21:20
  • This Blog seems to answer your question: http://blogs.msdn.com/b/drnick/archive/2006/03/31/565558.aspx I think the first and second answers here are relevant for you: http://stackoverflow.com/questions/4043683/wcf-httptransport-streamed-vs-buffered-transfermode?rq=1 – JPK May 20 '14 at 13:08
  • @JPK, I've been surprised to find out that the requirement from your link to have all input/output parameters be wrapped into some object is automatically met. There are several web methods in my WCF service with more then one input parameter. I've checked WSDL and saw that all of them are wrapped into element. I've switched service with several dozens of web methods and thousands of clients to Streamed transfer mode. It looks like it went smoothly. – finesoul Aug 19 '19 at 08:50

2 Answers2

8

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.

Haney
  • 32,775
  • 8
  • 59
  • 68
  • I THINK the streaming transfer mode could be considered an implementation detail for both the client and the server. Meaning that the server side could have Streaming transfer mode and the client could have buffered, or vica versa.. Is my assumption here correct? The the transfermode setting would only affect the internal performance characteristics of the client or the server (typically memory usage). – Andreas Presthammer May 24 '14 at 05:34
  • @AndreasPresthammer I believe you to be correct. It's hard to find good documentation on this stuff, but in my experience having streamed transfer mode generally is an implementation detail at either end. Both ends receive data, you just define when they begin to work on it (and your code might change to fit the necessary WCF contract constraints also). – Haney May 24 '14 at 16:27
  • To that point, streamed at both ends is often ideal as you can start sending as the data begins to arrive *and* start receiving as the data begins to arrive, vs having a bottleneck at the server and/or client of waiting for all data to be loaded into memory before continuing. – Haney May 24 '14 at 16:28
2

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."

bkqc
  • 831
  • 6
  • 25