I'm actually developing a Web Service in Java using Axis 2. I designed my service as a POJO (Plain Old Java Object) with public method throwing exceptions :
public class MyService {
public Object myMethod() throws MyException {
[...]
}
}
I then generated the WSDL using Axis2 ant task. With the WSDL I generate a client stub to test my service. The generated code contains a "MyExceptionException" and the "myMethod" in the stub declare to throw this :
public class MyServiceStub extends org.apache.axis2.client.Stub {
[...]
public MyServiceStub.MyMethodResponse myMethod(MyServiceStub.MyMethod myMethod)
throws java.rmi.RemoteException, MyExceptionException0 {
[...]
}
[...]
}
But when calling the method surrounded by a catch, the "MyExceptionException" is never transmitted by the server which transmit an AxisFault instead (subclass of RemoteException).
I assume the problem is server-side but don't find where. The service is deployed as an aar file in the axis2 webapp on a tomcat 5.5 server. The services.xml looks like this :
<?xml version="1.0" encoding="UTF-8"?>
<service name="MyService" scope="application">
<description></description>
<messageReceivers>
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
</messageReceivers>
<parameter name="ServiceClass">MyService</parameter>
<parameter name="ServiceTCCL">composite</parameter>
</service>
If the behavior is normal then I'll drop the use of Exceptions (which is not vital to my project) but I'm circumspect why Java2WSDL generate custom <wsdl:fault> in operation input & output declaration and WSDL2Java generate an Exception class (and declare to throw it in the stub method) if this is not usable...