File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Conversion of service specific exceptions to Runtime exceptions in WS.

 
Kumar Raja
Ranch Hand
Posts: 547
2
Hibernate Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

In the section 11.3 Web Services Interaction Results, I read the following


The following are possible ways of handling service-specific exceptions in client applications:
• Wrap the checked service-specific exceptions and throw an unchecked exception.
• Notify the user of the client application that an error has occurred.
• Do not allow service-specific exceptions propagate throughout the client application, but rather wrap them in exceptions specific to the client application.

This limits the impact of changes in the web service interface.
• Handle exceptions at one single place in the client application.
Prevents duplication of code and limits impact of changes in the web service interface.


Why do we need to convert service specific exceptions to run time exceptions, espicially when one of the artifacts being generated contains the servicespecific exception.

Say for example, if my service throws CustomException and on client side (java), one of the artifacts generated would be CustomException_Exception. I think handling CustomException_Exception would be easy and straight forward than handling some ArithmeticException (division by zero) or some other sort. How does this work in non-java client, when java webservice throws ArithmeticException, instead of custom exception.

Can you please explain me on this ?
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
The idea is that you have a client "layer", containing the generated artifacts and the code the uses the generated artifacts.
If you let service-specific exceptions "escape" this layer, then any changes in the service and the exceptions it "throws" will affect the client beyond the above mentioned "layer".
If you, in this layer, wrap or translate service specific exceptions to other, general, exceptions then any changes in the service and the exceptions it "throws" will not affect anything beyond the "layer" in the client.
Best wishes!
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic