aspose file tools*
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 Spring in Action this week in the Spring 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).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Custom Exceptions in Axis2