I have a initiative where I need to take in documents and convert them into images in a WCF application. When a file such as word document is passed through the stream, I will get multiple images for the document, i.e one image for each page in the document.
When I want to return these multiple images back to the client. Whats a good way to return all these files through the stream? I also need to tell the client what the names of the files would be and how many files I am returning, whats a good way to do that?
This is my first time working with WCF/web services.
I also need to consider how long a conversion is taking, if its taking too long or creating too many images I need to get back with an error. Is using SOAP faults a good way to tell the client?
Do I just make an array of byes and return the array to the client? or Do I combine all the images into one stream and return it? If the size of the stream is too big (i.e more than 2 MB) wouldn’t it have problems(slow) transferring the files?
You can transfer streams of any size and you shoudl probably just write the stream directly. To combine multiple files in a stream I think the easiest thing would be to create a zip file containing all content and sent that.
Your method signature should simply return a Stream which WCF will sent directly to the underlying binding. There are some limitations on which bindings you can use, but WebHttpBinding for one supports it.