Implementing file download via REST endpoint

WCF REST services by default convert the response content of service operations into either XML or JSON format. However, these two formats are definitely not the only formats we can use for responses of REST operations. By customizing the OperationContract of a service operation, we can make the operation return any arbitrary format of data, such as image, text, ZIP package, or even raw binary files.

In this recipe, we will use a custom REST service that returns files to client consumers as an example to demonstrate how we can use a REST service endpoint to return data in a customized format.

How to do it...

To return custom format data in a WCF REST service, the most important thing is designing the ...

Get Microsoft Windows Communication Foundation 4.0 Cookbook for Developing SOA Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.