Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > How to wrap all SoapExceptions

Reply
Thread Tools

How to wrap all SoapExceptions

 
 
Rachit Samwalla
Guest
Posts: n/a
 
      02-03-2005

Hi, I'm writing a fairly large web service and would like to be able to
pass more complex exceptions to the client to make things easier to
debug.

I understand that if you throw a SoapExecption() with the Detail field
populated with an XML node, this information gets passed to the client.

What I wish is to write a global wrapper for all my web service
functions that does the following:

try {
InvokeMethod();
} catch (SoapException e) {
// if its already a SoapException, just rethrow it.
throw e;
} catch (Exception e) {
// for all other exceptions, wrap it in a soap exception and
rethrow it.
// The wrapper will include things like line number of failures,
etc. in
// the Detail node.
throw new WrapperException(e);
}

What I cannot find is a place of putting this code such that I do not
have to change every single function in my WebService. Nothing to
override or anything. Only automated way I can think of is using a code
generator or mucking with the Emit library, which is less than ideal.

I'm sure others have faced this problem, but I have searched everywhere
and can't find anything.

Thanks!

 
Reply With Quote
 
 
 
 
Bruce Johnson [C# MVP]
Guest
Posts: n/a
 
      02-03-2005
You're having trouble, because such a place really doesn't exist. The other
alternatives (SoapExtensions and HttpHandlers) are either inconvenient or
will not contain enough information. The pattern in your example is the best
solution that I have seen.

"Rachit Samwalla" wrote:

>
> Hi, I'm writing a fairly large web service and would like to be able to
> pass more complex exceptions to the client to make things easier to
> debug.
>
> I understand that if you throw a SoapExecption() with the Detail field
> populated with an XML node, this information gets passed to the client.
>
> What I wish is to write a global wrapper for all my web service
> functions that does the following:
>
> try {
> InvokeMethod();
> } catch (SoapException e) {
> // if its already a SoapException, just rethrow it.
> throw e;
> } catch (Exception e) {
> // for all other exceptions, wrap it in a soap exception and
> rethrow it.
> // The wrapper will include things like line number of failures,
> etc. in
> // the Detail node.
> throw new WrapperException(e);
> }
>
> What I cannot find is a place of putting this code such that I do not
> have to change every single function in my WebService. Nothing to
> override or anything. Only automated way I can think of is using a code
> generator or mucking with the Emit library, which is less than ideal.
>
> I'm sure others have faced this problem, but I have searched everywhere
> and can't find anything.
>
> Thanks!
>
>

 
Reply With Quote
 
 
 
 
Rachit Samwalla
Guest
Posts: n/a
 
      02-03-2005
Thanks for the response.

I kind of figured there was no way to do this, since I looked carefully
at the complete stack trace while in a web method and found no good
class I could override and inject my wrapper.

This is fairly surprising. I'd think quite a few people would want this
and the interface designers would have forseen this.

 
Reply With Quote
 
Bruce Johnson [C# MVP]
Guest
Posts: n/a
 
      02-03-2005
I hear what you're saying and agree. Anytime that I have been designing a
production grade web service, those silly administrators keep wanting metrics
and exception logging. The b**tards. And, like I said, the pattern you
described seems to be the best way at the moment.

Even with something like a SoapExtension, you are still getting

"Rachit Samwalla" wrote:

> Thanks for the response.
>
> I kind of figured there was no way to do this, since I looked carefully
> at the complete stack trace while in a web method and found no good
> class I could override and inject my wrapper.
>
> This is fairly surprising. I'd think quite a few people would want this
> and the interface designers would have forseen this.
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
To wrap or not to wrap? Aaron Fude Java 12 05-10-2008 06:33 PM
Wrap computer components in bubble wrap? Ickshka Computer Support 7 05-05-2006 05:54 PM
Problems with SoapExceptions in custom HttpModule cj ASP .Net Web Services 0 10-11-2005 09:08 PM
SOAPExceptions don't go through the output filter pipeline carl ASP .Net Web Services 0 05-13-2004 12:46 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57