Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF - returning large images - your experience and tips on doing so

Tags:

c#

.net

wcf

We are using a WCF service layer to return images from a repository. Some of the images are color, multi-page, nearly all are TIFF format. We experience slowness - one of many issues.

1.) What experiences have you had with returning images via WCF 2.) Do you have any suggestions tips for returning large images? 3.) All messages are serialized via SOAP correct?
4.) Does wcf do a poor job of compressing the large tiff files?

Thanks all!

like image 939
schmoopy Avatar asked Dec 31 '22 09:12

schmoopy


2 Answers

Okay Just to second the responses by ZombieSheep and Seba Gomez, you should definitely look at streaming your data. By doing so you could seamlessly integrate the GZipStream into the process. On the client side you can reverse the compression process and convert the stream back to your desired image.

By using streaming there is a select number of classes that can be used as parameters/return types and you do need to modify your bindings throughout.

Here is the MSDN site on enabling streaming. This is the MSDN page that describes the restrictions on streaming contracts.

I assume you are also controlling the client side code, this might be really hard if you aren't. I have only used streaming when I had control of both the server and client.

Good luck.

like image 165
smaclell Avatar answered Jan 17 '23 15:01

smaclell


If you are using another .Net assembly as your client, you can use two methodologies for returning large chunks of data, streaming or MTOM.

Streaming will allow you to pass a TIFF image as if it were a normal file stream on the local filesystem. See here for more details on the choices and their pros and cons.

Unfortunately, you're still going to have to transfer a large block of data, and I can't see any way around that, considering the points already raised.

like image 20
ZombieSheep Avatar answered Jan 17 '23 15:01

ZombieSheep