C# 从WCF服务器到UWP客户端的流式视频

C# 从WCF服务器到UWP客户端的流式视频,c#,.net,wcf,uwp,streaming,C#,.net,Wcf,Uwp,Streaming,就像我在标题中写的: 在服务器端,我有以下方法: [OperationContract] Stream GetStream(); 它返回流,但当我在客户机中获取它时,它返回字节[]: public System.Threading.Tasks.Task<byte[]> GetStreamAsync() { return base.Channel.GetStreamAsync(); } 我还是不明白。是否有人像我一样遇到此错误,或者我如何使

就像我在标题中写的: 在服务器端,我有以下方法:

[OperationContract]
Stream GetStream();
它返回流,但当我在客户机中获取它时,它返回字节[]:

 public System.Threading.Tasks.Task<byte[]> GetStreamAsync() {
            return base.Channel.GetStreamAsync();
        }

我还是不明白。是否有人像我一样遇到此错误,或者我如何使用此返回类型进行流式处理。

也许您应该这样做

在WCF Web.config中添加端点

<endpoint address="files" behaviorConfiguration="WebBehavior"
      binding="webHttpBinding" bindingConfiguration="HttpStreaming"
      contract="WebService.IFileService" />
<endpoint address="data" binding="basicHttpBinding" contract="WebService.MyWCFService" />
在客户端。首先更新您的WCF服务参考,并在以下时间更新:

public async Task DownloadFile(string FileId)
    {
        string serverAddress = "http...../MyWCFService.svc";

        string filename = "test.txt";

        StorageFolder folder = KnownFolders.PicturesLibrary;
        var file = await folder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);

        BackgroundDownloader downloader = new BackgroundDownloader();
        DownloadOperation download = downloader.CreateDownload(new Uri($"{serverAddress}/files/DownloadFile?FileId={FileId}"), file);

        await download.StartAsync();
    }

我在我的WCF实例中没有看到它:尝试使用[WebInvoke]属性而不是[OperationContract]。或者在客户端看不到任何WCF方法?它会自动更改客户端中的返回类型:[WebInvoke]我无法定义它此函数是通过工具自动生成的。所以我用那种方法什么都不碰
public async Task DownloadFile(string FileId)
    {
        string serverAddress = "http...../MyWCFService.svc";

        string filename = "test.txt";

        StorageFolder folder = KnownFolders.PicturesLibrary;
        var file = await folder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);

        BackgroundDownloader downloader = new BackgroundDownloader();
        DownloadOperation download = downloader.CreateDownload(new Uri($"{serverAddress}/files/DownloadFile?FileId={FileId}"), file);

        await download.StartAsync();
    }