ollifant
ollifant

Reputation: 8616

WCF Streaming with result information

I am using a WCF to upload a file to a server.

public interface IFileTransferService
{
  [OperationContract]
  void UploadFile(Stream stream);
}

The problem here is, that I don't get information on whether the operation was succesful or not. Of course I may get an exception when the server does not respond, but how can the server report an specific error to the client.

Is this scenario supported by WCF? I am using .NET 4.0 both on the server and client. How else could I archive the desired behavior?

Thanks for your help!

Upvotes: 0

Views: 155

Answers (2)

flayn
flayn

Reputation: 5322

If the call completes no error has occured. You should also wrap the call in a try-catch block and check for FaultExceptions.

Also what Ladislav said: add a return value.

Upvotes: 2

Ladislav Mrnka
Ladislav Mrnka

Reputation: 364409

You can modify your UploadFile operation to return value / DataContract instead of void to report operation result.

Upvotes: 2

Related Questions