views:

32

answers:

1

We are working on a web application. All pages of this web application inherits from a base page, and we have a mechanism like

 this.Error += new EventHandler( Page_Error );

 private void Page_Error( object sender, EventArgs e )
    {
        Helper.LogError( this.Context );
    }

The above works pretty fine in all webpages.

Now we want to add couple of web services in our application. We also have a Base Service from which all other services will be inherited. However I am not able to setup a proper error loggin mechanism in webservice so far. Becase, I am not able to identify any event on which I could get the error info without putting Try Catch at respective service method calls.

Can someone suggest a strategy in such cases to have a commong generic error handling mechanism for web services.

A: 

Assuming that by .net web service you mean WCF, then you can use FaultContracts etc as explained here.

There is also another way to handle it, which works for both WCF and asmx web services:

  • Let all you Data Transfer Objects inherit from a "Error Information" object
  • In each service, have a try catch
  • In the catch, populate the Error Information with relevant data
Shiraz Bhaiji
Sorry I was not clear in my question but I actually meant traditional Web Service (.asmx)
Subhash Dike