2015-01-09 52 views

回答

0

是的,只要您接受並返回Stream並使用WebHttpBinding即可。見Can a WCF REST endpoint be forced to accept Raw message format?How to: Create a Service That Returns Arbitrary Data Using The WCF Web HTTP Programming Model

基本上如下:

[WebInvoke(Method = "POST", UriTemplate = "processImage")] 
public Stream ProcessImage(Stream inputImage) 
{ 
    // do stuff with inputImage 
    WebOperationContext.Current.OutgoingResponse.ContentType = "image/jpeg"; 
    return /* some stream with jpeg data */; 
} 

從客戶端,你只是發佈一個HTTP請求。請參閱Sending images using Http Post,但使用生成的HttpResponseaccess the returned image

+0

Thanks @Mitch它幫助了很多 –