How to log the unhandled web service exceptions

 Unlike ASP.NET, unhandled web services exception can not be caught in global.asax(Application_Error event). Here is the workaround for that

1.Create a SoapExtension class
2.Add the SoapExtensionTypes element in your web.config file and configure your SoapExtension class.
3.In the overrided ProcessMessage method, check whether SoapMessage.Exception has any value
4.Log the exception details only if the SoapMessageStage is SoapMessageStage.AfterSerialize.
5.Make sure ASP.NET account has enough permission to write the log

More about SoapExtension class from MSDN

http://msdn.microsoft.com/en-us/library/system.web.services.protocols.soapextension(VS.71).aspx

1 Comment

  • Hi,
    perhaps you can help me:
    i am calling a .net webservice but it returns with 'http 500 - internal server error'

    i would like to find out what the cause of this error is by logging it to a file (on the remote server). this is however an unhandled exception, so i don't know how to do it. global.asax doesnt work, neither looking into the innerexception.

    could you shed some light?

    thanks!

    Bas

Comments have been disabled for this content.