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
Joined: Aug 19, 2005
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).