views:

101

answers:

2

I am developing a broker service which accepts a clients request to search for an image with certain tags. I have an existing web service in C# 2.0 which delivers the requested info and due to business rules, I cannot expose my 2.0 webservice to the new client and hence the need for my broker service which will invoke my 2.0 webservice and obtain the handle/location to the image and then try to stream it as the output of the WCF service call

The images could be between 1MB to 20MB in size. What is the best way to stream this data in WCF?

+2  A: 

use MTOM attachments. See this article for a comparison and explanation: http://msdn.microsoft.com/en-us/library/ms733742.aspx

Manu
A: 

Change your response type and write your file

Response.ContentType = "image/jpeg";

Response.WriteFile(fileNameAndPath);
Response.End();

alternatively if you have the image loaded in memory

Response.ContentType = "image/jpeg";

Response.OutputStream.Write(imageBytes, 0, bytesLength);
Response.End();
Ramesh Soni