views:

269

answers:

1

Hi,

In order to support streaming i return Message with override to OnWriteBody...
The problem is if an exception is thrown in the OnWriteBody (DB timeout or whichever)
The ProvideFault in the IErrorHandler is not called and therefore i have no way to propagate the error to the client( via a filtering in the IErrorHandler).
Is there a way to solve this.

Thanks.

A: 

when doing streaming with WCF I create two ServiceContracts one that does the streaming another that will send the notification at the end of the streaming.

The response ServiceContract I use a duplex type binding. The client as to call the response ServiceContract first to get a ticket for its transaction then call my transfer ServiceContract. Then at the end of the transaction the client will get notified of success or failure from the response ServiceContract.



[ServiceContract]
public interface IStreamFileService
{
  [OperationContract]
  void Upload(Stream stream);
}

[ServiceContract(SessionMode = SessionMode.Required, CallbackContract = typeof(ITransferCallback))]
public interface IStreamFileResponseService
{
  [OperationContract(IsOneWay = false, IsInitiating = true, IsTerminating = false)]
  Guid StartUpload();
}

[ServiceContract]
public interface ITransferCallback
{
  [OperationContract]
  void OperationComplete(ResponseMessage response);
}

I do this in two services because my requirements and workflow requires me to track many things and do authentication, validation, etc.

Emmanuel