tags:

views:

1453

answers:

3

Hello,

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!!

A: 

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.

Mitch Baker
A: 

Hello,

Use WCF transport in streamed mode or/and long-running active object pattern. Please, follow this article for more details or contact me.

igor
+1  A: 

Depending how much time the processing takes you might be better of 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 OutOfMemeory Exceptions.

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


  [OperationContract]
  Stream GetProcessedFile(Guid fileId);

  // and probably this if you want to poll whether the service has finished processing
  [OperationContract]
  bool IsFileProcessed(Guid fileId);

}
Flo