tags:

views:

430

answers:

1

I have a WCF service and one of the method returns Stream. Now the question is while I try to consume that Stream object, am I trying to use the stream over the network or the client had received the full stream on its own side?

Will it make any difference if I would have used RESTful instead of WCF?

+2  A: 

The whole point of using the streaming interface in WCF is that the client gets a stream from which it can read blocks of bytes. The whole return object (file, picture, video) will NOT be assembled in full on the server and sent back as once huge chunk, instead, the client can retrieve chunks at a time from the stream returned from the WCF service.

Your client gets back a "Stream" instance, from which it can then read the data, like from a FileStream or a MemoryStream. That way, the amount of memory needed at any given time is reduced to a manageable size (instead of potentially multiple gigabytes in the buffered mode, you'll transfer a large file in e.g. 1 MB chunks or something like that).

Marc

marc_s
should i be using any specific binding when returning Stream back?
Miral
Depends - are you internally, behind a corporate firewall? Then I'd recommend netTcp. Do you need to support external (internet) clients? Then basicHttp is your choice.
marc_s
Do we need to close the stream ? if yes will it be accessible at the client?
Miral
The client will need to close the stream after it's done reading it.
marc_s
i am closing the stream at the client end but if i try to delete that image with File.Delete it says 'currently in use by other proecess'.
Miral