-2

我有一个 WCF REST 服务,它必须以其中一种方法提供视频。界面如下所示(我没有提供实现,因为问题出在此处)。 [ContentType]被识别,但我得到一个System.Net.Mime.ContentType is a type but is used like a variable.

请帮忙!我不知道该怎么做

public interface MyService
{    
    //stream video from camera
    [WebGet(ContentType("video/x-msvideo"), UriTemplate = "video/preview")]
    [OperationContract]
    Bitmap VideoPreview();     
}
4

1 回答 1

0

ContentType不是属性,也不是 的属性WebGetAttribute

根据@Faizan 的链接,您无法使用 REST 服务完成您尝试做的事情 - 他们根本不支持这一点。您可以尝试根据@anony 的链接在您的实现中明确设置输出格式:

public interface MyService
{
    //stream video from camera
    [WebGet(UriTemplate = "video/preview")]
    [OperationContract]
    Bitmap VideoPreview();     
}

public class MyServiceImpl : MyService
{
    public Bitmap VideoPreview()
    {
        // code to get video etc...
        WebOperationContext.Current.OutgoingResponse.Headers[HttpResponseHeader.ContentType] = "video/x-msvideo";
    }     

}

于 2014-02-19T07:45:16.890 回答