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

Eclipse CDT / cygwin: Use compiler command as default for all projects

gcc c++11 g++ eclipse-cdt

Using Eclipse CDT, I would like to use the -std=c++11 command for the GCC C++ compiler as the standard argument across all projects.