Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WCFWeb服务:上传一个文件,处理该文件,下载处理后的文件_Wcf_C# 3.0 - Fatal编程技术网

WCFWeb服务:上传一个文件,处理该文件,下载处理后的文件

WCFWeb服务:上传一个文件,处理该文件,下载处理后的文件,wcf,c#-3.0,Wcf,C# 3.0,我可以处理文件部分的过程,但在我发疯之前,是否有人构建了一个简单的wcf服务&客户端(在windows服务或IIS下运行),我可以用它上传文件,然后下载回来?代码行数最少?(C#或VB) 压缩和加密将是很酷的,但我将层稍后 谢谢 你应该能够相当容易地做到这一点。服务合同可能如下所示: [ServiceContract] public interface IFileService { [OperationContract] byte[] ProcessFile(byte[] FileDat

我可以处理文件部分的过程,但在我发疯之前,是否有人构建了一个简单的wcf服务&客户端(在windows服务或IIS下运行),我可以用它上传文件,然后下载回来?代码行数最少?(C#或VB)

压缩和加密将是很酷的,但我将层稍后


谢谢

你应该能够相当容易地做到这一点。服务合同可能如下所示:

[ServiceContract]
public interface IFileService
{
  [OperationContract]
  byte[] ProcessFile(byte[] FileData);
}
加密部分可以由WCF使用传输级安全性进行本地处理。我不认为WCF直接支持压缩,但是您可以使用GZipStream类添加它


我并没有像你们描述的那个样构建一个文件处理服务,但我构建了一个处理字节数组数据的服务,该数据在WCF客户端和服务之间来回传递。它很好用

以流模式或/和长时间运行的活动对象模式使用WCF传输。
请按此了解更多详细信息或与我联系。

根据处理所需的时间,您最好使用两种方法,以避免遇到超时问题

另外,我同意Igor,您应该使用流,而不是字节[]。否则,您可能会遇到OutOfMemory异常

[ServiceContract]
public interface IFileService
{
  // returns a Guid which you can use later to request the processed files
  [OperationContract]
  Guid SendFileToProcess(stream streamedFile);

  [OperationContract]
  Stream GetProcessedFile(Guid fileId);

  // use this to poll whether the service has finished processing
  [OperationContract]
  bool IsFileProcessed(Guid fileId);
}