WCF Web Service: Upload a file, Process that file, Download that processed file back

I can handle the process that file part, but before I go crazy, has someone built a simple wcf service & client (running under windows services or IIS) that I can use to upload a file, and download that file back? with the fewest lines of code? (C# or VB)

compression & encryption would be cool, but i'll layer that on later!!

Thanks!!

Answers


You should be able to do this fairly easily. The service contract would probably look like this:

[ServiceContract]
public interface IFileService
{
  [OperationContract]
  byte[] ProcessFile(byte[] FileData);
}

The encryption part could be handled natively by WCF using transport level security. I don't believe that WCF supports compression directly, but you could add that using the GZipStream class.

I have not built a file handling service as you describe, but I have built a service that handles byte array data that is passed back and forth between a WCF client and service. It works just fine.


Depending how much time the processing takes, you might be better off using two methods in order to avoid running into timeout issues.

Also, I agree with Igor, you should use streams and not byte[]. Otherwise you will probably run into OutOfMemory Exceptions.

[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);
}

Need Your Help

What are the benefits of using partitions with the Enterprise edition of SQL 2005

sql sql-server-2005 partitioning

I'm comparing between two techniques to create partitioned tables in SQL 2005.

Cannot target a specific div to populate data from jQuery AJAX ASP.NET

c# javascript jquery asp.net ajax

So I have the following Javascript. I will try and figure out why the text specified inside the CommentItem div I am appending isn't showing.. But my main issue is targetting ContainerPh the one th...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.