Hi,
I'm currently using Java Reflection to load my service locator, getting
ports and invoke operations. Everything works fine for me apart from catching
exceptions. As I'm currently aware, whatever AxisFault thrown by the web
service call is wrapped under my InvocationTargetException which is available
to me via the getCause() or getTargetException() method.
However, I cannot seem to cast the AxisFault into my specific exceptions.
Given my port type operation signature is like this
public void myop(pars... ) throws ... MyPackage.StringMessage;
My (reflection) Java code are as follows
try {
Method methodOp;
Class serviceLocatorClass = Class.forName(...);
Object serviceLocator = serviceLocatorClass.newInstance();
Method getPortMethod = serviceLocatorClass.getMethod();
Object port = getPortMethod.invoke(serviceLocator, null);
Method webServiceOp = port.getClass().getMethod(myop, parClasses);
Object result = webServiceOp.invoke(port, pars);
} catch (InvocationTargetException ex) {
if (ex.getTargetException() instanceof AxisFault) {
Class stringMessage = // do loading of StringMessage via
forName
ex.getTargetException().getClass().getName();// returns
AxisFault which is not what i want as i'm expecting StringMessage
stringMessage.cast(ex.getTargetException());//
encountered ClassCastException
}
}
When my webs service throws StringMessage exception (I'm certain this is
the thrown), I cannot seem to cast it successfully. I found out that
ex.getTargetException().getClass().getName() returns me AxisFault instead of
StringMessage.
I then try the static way, which
try {
port.myOp(...);
} catch (AxisFault ex) {
ex.getTargetException().getClass().getName();// returns
StringMessage!
}
Would appreciate advice on this! Many thanks in advance!
Best Regards,
Larry
--
The University of Stirling (a charity registered in Scotland, number
SC 011159) is a university established in Scotland by charter at Stirling,
FK9 4LA. Privileged/Confidential Information may be contained in this
message. If you are not the addressee indicated in this message (or
responsible for delivery of the message to such person), you may not
disclose, copy or deliver this message to anyone and any action taken or
omitted to be taken in reliance on it, is prohibited and may be unlawful.
In such case, you should destroy this message and kindly notify the sender
by reply email. Please advise immediately if you or your employer do not
consent to Internet email for messages of this kind.