将图像从android发布到WCF Rest服务并获取响应作为图像

时间:2015-01-09 06:55:35

标签: android wcf rest

我需要将图片发布到 wcf服务,服务会对图片和响应图片执行一些操作。怎么做?我需要双方的帮助 android和wcf

1 个答案:

答案 0 :(得分: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,但请将结果HttpResponse用于access the returned image