我需要将图片发布到 wcf服务,服务会对图片和响应图片执行一些操作。怎么做?我需要双方的帮助 android和wcf
答案 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。