views:

15

answers:

0

Hello,

I am happily using Castle's WcfFacility. From Monorail I know the handy concept of Rescues - consumer friendly results that often, but not necessarily, contain Data about what went wrong. I am creating a Silverlight application right now, doing quite a few WCF service calls. All these request return an implementation of

public class ServiceResponse
{
    private string _messageToUser = string.Empty;
    private ActionResult _result = ActionResult.Success;

    public ActionResult Result // Success, Failure, Timeout
    {
        get { return _result; }
        set { _result = value; }
    }

    public string MessageToUser
    {
        get { return _messageToUser; }
        set { _messageToUser = value; }
    }
}

public abstract class ServiceResponse<TResponseData> : ServiceResponse
{
    public TResponseData Data { get; set; }
}

If the service has trouble responding the right way, I would want the thrown Exception to be intercepted and converted to the expected implementation. base on the thrown exception, I would want to pass on a nice message.

here is how one of the service methods looks like:

    [Transaction(TransactionMode.Requires)]
    public virtual InsertOrUpdateResponse InsertOrUpdate(WarehouseDto dto)
    {
        var w = dto.Id > 0
                    ? _dao.GetById(dto.Id)
                    : new Warehouse();
        w.Name = dto.Name;
        _dao.SaveOrUpdate(w);
        return new InsertOrUpdateResponse
                   {
                       Data = new InsertData
                                  {
                                      Id = w.Id
                                  }
                   };
    }

I need the thrown Exception for the Transaction to be rolled back, so i cannot actually catch it and return something else.

Any ideas, where I could hook in?