I have a WCF Rest Service service project configured to serve JSON data structures. I defined the contract in the interface file, for example:
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "location/{id}")]
Location GetLocation(string id);
Now the WebService should return multimedia documents (images, PDF documents), as a standard web server does. WCF WebMessageFormat ResponseFormatonly supports JSON or XML. How to define a method in an interface to return a file?
Sort of:
[OperationContract]
[WebInvoke(Method="GET",
ResponseFormat = ?????
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "multimedia/{id}")]
???? GetMultimedia(string id);
So: wget http://example.com/multimedia/10returns a PDF document with id 10.
source
share