【发布时间】:2011-11-18 23:22:04
【问题描述】:
我正在使用 WCF 创建一些 REST 服务。 Rest Service 方法之一需要获取字节数组作为参数(图片为字节数组)并返回一些对象。 我使用 IIS 运行此服务。 但这不起作用。
我写的代码:
[ServiceContract]
public interface IPicService
{
[OperationContract, WebInvoke(Method="POST", UriTemplate = "GetPicReport/{imageName}")]
Report GetPicReport( string imageName, Stream image );
}
[ServiceBehavior( AddressFilterMode = AddressFilterMode.Any )]
public class PicService: IPicService
{
public Report GetPicReport( string imageName, Stream image )
{
return new Report ();
}
}
我使用资源管理器检查此代码 - 但我收到有关缺少参数(图像流)的错误
我该如何测试它? 我无法使用 WCF 测试客户端 - 所以我编写了创建 http 调用的简单应用程序 - 此方法返回错误 404(未找到服务器)
【问题讨论】:
-
您说您将参数作为字节数组传递,但您的代码使用 Stream,而不是 byte[]。
-
首先 - 我发送字节数组,第二个参数是字节数组。但是我将其更改为 Stream 并且仍然无法从我编写的测试应用程序中工作。
标签: wcf