Question on Exception Handeling in webservices?

L

ltnats

Hi there,
I have been developing a webservices data access layer for a
project I am working on. I have researched exception handling in
webservices and found that global handling of unhandled exceptions can
be done using a SOAP Extension. I have implemented one of these
successfully. However if the webservice does not get invoked with a
client proxy; (eg using a HTTP Get request like when you press the
Invoke button in IE after browsing to the service.asmx file) the SOAP
Extension does not get executed and as a result neither does my global
exception handler. Information about the exception is returned to the
browser in text form, showing the error and method/line number it
happened on. I want to prevent this from happening and log the
exception details and send back a SOAP Exception as I do in my global
exception handler. How can I do this for HTTP Get requests on my
webservices?

Thank you for your time,

Scott.
 
S

Simon Hart

I must admit I have never heard of using a SoapExtension to handle unhandled
exceptions via ASP.NET Web Services. Do you have a link to the site you
learned this from? Generally SoapExtensions are used to trap the SOAP
messages so you can modify or log data. Usually you wouldn't write your
exception handling logic around this.

Have you not tried using the Global.asax Application_Error then calling
Context.Error.GetBaseException to handle unhandled exceptions?

I must admit I always disable HTTPGET and HTTPPOST to avoid malicious hacker
attempts.

Regards
Simon.
 
D

Dale

Depending on your application and expected consumers of your webservice, you
might also consider what I do in some web services: I catch the exception in
my webmethod and return an out parameter:

[WebMethod]
public string HelloWorld(out string error)
{
.......
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top