Re: Code design ideas?



I implemented the following pattern in my webservice. Below is a
simplified view.
When calling a webmethod, I see two types of errors:
1. Subsystem errors. Like: there is no connectivity between the client
app and the webservice, etc. These are errors that are independent from
my code inside the webservice

2. System errors. These errors are the direct or indirect effect of my
code inside the webservice. Like: executing a select statement while
the database is down, or raising an error from inside my own code, etc,
etc.

Now, my design pattern says:

A. Errors of type 1 should be handled by the client side. For example,
you should identify the error and display "There is no conectivity with
the server", etc.

B. Errors of type 2 should ALWAYS be handled by my code. Then the
caught exception will be sent to a method that will identify it and
will assign a unique error code along with some text that will describe
the error. Usually it is the Message of the Exception.
Unidentified exception should have also an error code. I also assign a
severity level for each identified exception; for now, I have only 2
severity levels: warning and error.
So, when an exception of type 2 occurs, I create an XML string
containing:
- the error code obtained after the exception is identified
- the error text. Each exception caught has a Message
- the severity level; my case: warning or error

Now, the information about the error is ready. We only have to
transport it to the client.
I chose to transport it using an SoapException object. How? I fill the
Detail member with the information about the error and throw the
SoapException object.
The client will listen for exceptions of SoapException type and will
analyse them.
If the object caught has its Detail member null, then we know that the
exception is of type 1 and try to identify the exception on the client
side. If Detail property is not null, you just have to interpret the
data contained inside and provide to the user the apropriate feedback.

Now, in my real application, I have to deal with errors and warnings
inside my webservice. Errors are simple: when you encounter one just
rollback some operations if needed and exit. Anyway, warnings bring a
bit of complexity here. I mean, you need to warn the user about
something, but this doesn't mean you have to exit. Au contraire, you
need to continue processing and at the end TO RETURN THE RESULT OF
PROCESSING.

I solved this issue by defining a Response object that contains 2 main
parts:
1. A header containing error and/or warning messages. Why multiple?
Because when processing, you could yield multiple warning messages in a
single request.
2. A data section that contains the results of the processing.

My methods always return an xml string that describe such an Response
object that will be recreated on the client side.





Hi Adi,
Is this a standard pattern or an home made one? I strive to use standard
method. But i do understand they might not always apply in particular cases.
If what you describe is in fact a standard pattern then, where can i read
more about it?


Many thanks
JJ


.



Relevant Pages

  • Re: Code design ideas?
    ... I implemented the following pattern in my webservice. ... Usually it is the Message of the Exception. ... severity levels: warning and error. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: WSE 2.0 and structured Exceptionhandling
    ... all Webservice inherit from a base webservice class ... This Document is then passed along to the SoapException. ... On the client, I've created a WebServiceInvokationException which unwraps ... >> When I throw an exception on the server side, ...
    (microsoft.public.dotnet.framework.webservices.enhancements)
  • What do you think of this warning message?
    ... Text copy of the warning page appeared under Firefox 2.0.0.6 ... Request Validation has detected a potentially dangerous client ... An unhandled exception was generated during the execution of the current web ...
    (comp.security.misc)
  • Re: Code design ideas?
    ... No standard pattern I read about satisfied all my needings. ... Errors of type 1 should be handled by the client side. ... Usually it is the Message of the Exception. ... severity levels: warning and error. ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Problemes with custom Webservices and security.
    ... that generates exception in your finally block. ... the ASP.NET will redirect your client to the error page. ... security context. ... > I have a client that calls a Webservice, ...
    (microsoft.public.sharepoint.portalserver.development)