Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > pasring SOAP exceptions

Reply
Thread Tools

pasring SOAP exceptions

 
 
PJ6
Guest
Posts: n/a
 
      03-20-2008
I would like to distinguish between two classes of exceptions thrown from my
web service - one that is a standard exception that is not propogated to the
UI and indicates a problem, and one that contains an error message (such as
a validation failure) intended for the user.

Problem is, any exception thrown from this web service ends up wrapped
within a SOAP exception and has its message mashed up with other
information, including the stack trace.

Now I suppose I can find a way around this problem, but I get the impression
that the web service model is simply not designed for this particular mode
of use. Should I give up trying to pass user-destined exceptions from the
web service?

Paul


 
Reply With Quote
 
 
 
 
George Ter-Saakov
Guest
Posts: n/a
 
      03-20-2008
Usually your WebService methods return objects that have error information
embedded in it. So SOAP/hard exception and application exceptions are
different.

Example in C#

class clsResponse
{
public bool bSuccess = true;
public string sErrMessage = "";
}

class clsRateQuoteResponse : clsResponse
{
public decimal dAmount;
}

[WebMethod]
public clsRateQuoteResponse GetRates(clsRateQuoteRequest rq)
{
try
{
...blablabla....
clsRateQuoteResponse rs = new clsRateQuoteResponse();
if( invalid zip code )
{
rs.bSuccess = falsel;
rs.sErrMessage = "Incorrect zip code";
return rs;
}
...balablabla....
rs.dAmount = $1000M;
rs.bSuccess = true;
return rs;
}
catch(Exception e)
{
....Log exception.......and throw SOAP exception
throw new Excpetion("Sorry, we have an internall error. Please try
again later");
}
}

So if it's a soft error (the one that can be fixed on receiving end like
fixing address for example) you end up with normal response,

For hard errors (like database just died) I prefer to log them/page admin
and respond with SOAP exception.


George.

"PJ6" <> wrote in message
news:%...
>I would like to distinguish between two classes of exceptions thrown from
>my web service - one that is a standard exception that is not propogated to
>the UI and indicates a problem, and one that contains an error message
>(such as a validation failure) intended for the user.
>
> Problem is, any exception thrown from this web service ends up wrapped
> within a SOAP exception and has its message mashed up with other
> information, including the stack trace.
>
> Now I suppose I can find a way around this problem, but I get the
> impression that the web service model is simply not designed for this
> particular mode of use. Should I give up trying to pass user-destined
> exceptions from the web service?
>
> Paul
>



 
Reply With Quote
 
 
 
 
PJ6
Guest
Posts: n/a
 
      03-20-2008
Ahh... yes that is a better way to do it.

Thanks,
Paul

"George Ter-Saakov" <gt-> wrote in message
news:...
> Usually your WebService methods return objects that have error information
> embedded in it. So SOAP/hard exception and application exceptions are
> different.
>
> Example in C#
>
> class clsResponse
> {
> public bool bSuccess = true;
> public string sErrMessage = "";
> }
>
> class clsRateQuoteResponse : clsResponse
> {
> public decimal dAmount;
> }
>
> [WebMethod]
> public clsRateQuoteResponse GetRates(clsRateQuoteRequest rq)
> {
> try
> {
> ...blablabla....
> clsRateQuoteResponse rs = new clsRateQuoteResponse();
> if( invalid zip code )
> {
> rs.bSuccess = falsel;
> rs.sErrMessage = "Incorrect zip code";
> return rs;
> }
> ...balablabla....
> rs.dAmount = $1000M;
> rs.bSuccess = true;
> return rs;
> }
> catch(Exception e)
> {
> ....Log exception.......and throw SOAP exception
> throw new Excpetion("Sorry, we have an internall error. Please try
> again later");
> }
> }
>
> So if it's a soft error (the one that can be fixed on receiving end like
> fixing address for example) you end up with normal response,
>
> For hard errors (like database just died) I prefer to log them/page admin
> and respond with SOAP exception.
>
>
> George.
>
> "PJ6" <> wrote in message
> news:%...
>>I would like to distinguish between two classes of exceptions thrown from
>>my web service - one that is a standard exception that is not propogated
>>to the UI and indicates a problem, and one that contains an error message
>>(such as a validation failure) intended for the user.
>>
>> Problem is, any exception thrown from this web service ends up wrapped
>> within a SOAP exception and has its message mashed up with other
>> information, including the stack trace.
>>
>> Now I suppose I can find a way around this problem, but I get the
>> impression that the web service model is simply not designed for this
>> particular mode of use. Should I give up trying to pass user-destined
>> exceptions from the web service?
>>
>> Paul
>>

>
>



 
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
Exceptions - How do you make it work like built-in exceptions? Lie Python 3 01-14-2008 06:45 PM
Exceptions + Performance on path without exceptions gratch06@gmail.com C++ 3 04-16-2007 08:52 PM
Simple library for arithmetic expression pasring and evaluating John Doe Java 0 04-17-2005 10:03 PM
Checked exceptions vs unchecked exceptions Ahmed Moustafa Java 5 07-14-2004 01:46 PM
Custom exceptions -- inherit from exceptions.Exception? Paul Miller Python 3 11-12-2003 09:24 AM



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