This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Services and the fly likes Custom Exceptions in Axis2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Custom Exceptions in Axis2" Watch "Custom Exceptions in Axis2" New topic
Author

Custom Exceptions in Axis2

Shashidhar Yarabati
Ranch Hand

Joined: Jun 17, 2007
Posts: 175
Iam new to webservices. I am using Axis2 webservices and creating stubs using wsdl2java tool. everything is fine but my costimized exceptions is not coming to client. He is getting only AxisFault exception. I don't want to allow him to see that. Instead I want to see him my own exception instead of that.
Can any body help me on this?


Shashidhar<br /> SCJP 1.5<br /> SCWCD 5.0
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
What you are asking for isn't possible. The WSDL can only specify the SOAP faults that your service will issue. There is no way to indicate how to map those SOAP faults to Java exceptions - mainly because the client may not even be written in Java. So all the SOAP fault to exception mapping has to be configured and coded on the client side.

In fact you shouldn't make any assumptions on what the message representations on the client side will look like. All you can count on is what is in the WSDL which only defines SOAP request, response and fault messages and XML datatypes (no objects or exceptions).

To provide the client with your custom exceptions you would have to write a client API that wraps around the client stub and intercepts the SOAP faults and re-throws them as your custom exceptions.

Depending on the binding framework you are using you may be able to provide additional configuration files that will do the work for you (JiBX example). However that means that your client has to have your Java exceptions (and possibly objects), the configuration files and has to use the same binding framework - in addition to your WSDL (harmonized data types always result in tight coupling).
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Custom Exceptions in Axis2
 
Similar Threads
AXIS2 WS-Security
Axis2 parameter ordering is wrong when not all elements are not passed
RESTFul webservice with axis2
Invoking a Handler specific to a operation in axis2
Handling exceptions in Axis2 webservices top down approach