正如主题所说,我从 Wcf 休息服务接收图像时遇到问题。端点似乎没问题,但我只得到空数据。
网络配置:
<service name="RestService.RestServiceImpl" behaviorConfiguration="ServiceBehaviour">
<endpoint address ="" binding="webHttpBinding" contract="RestService.IRestServiceImpl" behaviorConfiguration="web"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
SVC:
[OperationContract]
[WebGet(UriTemplate = "GetImage", RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Bare)]
Stream GetImage();
public Stream GetImage()
{
var ms = new MemoryStream();
Resource1.batman.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
WebOperationContext.Current.OutgoingResponse.ContentType = "image/png";
return ms;
}
标记:
<%@ ServiceHost Language="C#" Debug="true" Service="RestService.RestServiceImpl" CodeBehind="RestServiceImpl.svc.cs" Factory="System.ServiceModel.Activation.WebServiceHostFactory"%>