Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

pasring SOAP exceptions

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
PJ6 - 20 Mar 2008 15:59 GMT
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
George Ter-Saakov - 20 Mar 2008 16:31 GMT
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.

>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
[quoted text clipped - 11 lines]
>
> Paul
PJ6 - 20 Mar 2008 16:58 GMT
Ahh... yes that is a better way to do it.

Thanks,
Paul

> Usually your WebService methods return objects that have error information
> embedded in it. So SOAP/hard exception and application exceptions are
[quoted text clipped - 62 lines]
>>
>> Paul

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.