Casting AxisFault from InvocationTargetException.getTargetException)

2008-05-08 Thread Larry Tan
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.




Distinguish axis engine(s) in Tomcat

2006-03-31 Thread Larry Tan
Hi,
I'm new to Axis. I'll like to find out if i have 2 servlets (both 
extending
AxisServlet) deployed under same webapp, will there be 2 separate engines or
both of them sharing 1 Axis engine? Is there anyway of distinguishing them?
Another question: If i have a subclass of AxisServlet in a webapp and
AxisServlet in another webapp, it'll be 2 Axis Engine i suppose? Is there
anyway of letting them share 1 engine across different webapp?
The reason i asked is because I'm trying to get ActiveBPEL to work with
WSRF (deployed in Tomcat).

Thanks,
Larry Tan


-- 
The University of Stirling 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.