Hello Jack,
As Jarmo pointed out, all client-side (generated) exceptions extend
AxisFault. Are you not using the generated exceptions?
The WSDL defines the interface, including the faults. Either you let
Axis do the mapping to Java using its own generated classes, or you do
not. I don't think Axis could do its job without them.
There is no need to catch an AxisFault first and then doing an
instanceof. Jarmo must have written that code before he had his coffee ;)
Your client does not (and should not) need to know that AxisFault is
being used internally.
Could you show us the WSDL that defines your fault (complexType +
<message>, etc.), the SOAP response containing the fault, and the code
you use to catch the exception?
Regards,
Dies
Jack Lund wrote:
Yeah, I can see that that would be easier. Unfortunately, I have no
control over the exceptions being thrown - I just need the client-side
to be able to catch them *as* the exceptions that are originally thrown.
I also am doing dynamic proxying rather than stubs/skeletons, so it
makes it that more complicated.
From the debugging I've been able to do, it looks like the fault coming
across contains the fully-qualified package name of the exception class,
but for some reason on the client side it's not creating the exception.
Since this is an area where there's practically no documentation, I'm
finding myself pretty much randomly trying different things and seeing
if they work.
The user's guide is really vague about this subject:
"If a method is marked as throwing an Exception that is not an instance
or a subclass of java.rmi.RemoteException, then things are subtly
different. The exception is no longer a SOAP Fault, but described as a
wsdl:fault in the WSDL of the method. According to the JAX-RPC
specification, your subclass of Exception must have accessor methods to
access all the fields in the object to be marshalled /and/ a constructor
that takes as parameters all the same fields (i.e, arguments of the same
name and type). This is a kind of immutable variant of a normal JavaBean
<http://java.sun.com/products/javabeans>. The fields in the object must
be of the datatypes that can be reliably mapped into WSDL.
If your exception meets this specification, then the WSDL describing the
method will describe the exception too, enabling callers to create stub
implementations of the exception, regardless of platform."
I was kind of hoping someone else out there would have had some
experience with getting this to work.
-Jack
Jarmo Doc wrote:
I have an Axis client stub which was generated from WSDL. *All* of
the client-side user-defined exceptions extend org.apache.axis.AxisFault.
The equivalent exceptions at the server also extend
org.apache.axis.AxisFault, rather than Exception.
This is a decidedly dodgy area, imo, especially when it comes to
interop with non-Axis clients.
From: Jack Lund <[EMAIL PROTECTED]>
Reply-To: axis-user@ws.apache.org
To: axis-user@ws.apache.org
Subject: RE: Problems getting user exceptions to work
Date: Wed, 29 Mar 2006 14:51:47 -0600
Nope, didn't work. Wouldn't think it would - AxisFault isn't a
subclass of InvalidDateException.
-Jack
Jarmo Doc wrote:
Try doing this:
catch (AxisFault ex)
{
if (ex instanceof InvalidDateException)
{
InvalidDateException myex = (InvalidDateException)ex;
// deal with myex here
}
// deal with others here
}
From: Jack Lund <[EMAIL PROTECTED]>
Reply-To: axis-user@ws.apache.org
To: axis-user@ws.apache.org
Subject: Problems getting user exceptions to work
Date: Wed, 29 Mar 2006 12:21:33 -0600
Hi. I'm using axis 1.2.1, and I'm trying to get the exceptions sent
by my service thrown to the client. For instance, my service can
throw an "InvalidDateException" exception, which is a subclass of
java.lang.Exception, and I want the client code to get that
exception. What little is said on the axis website about this
implies that it should "just work", but it doesn't seem to - what I
get on the other side is an AxisFault with the message string from
my exception embedded inside.
Is there something special I have to do, on either side, to get
this to work?
Thanks.
-Jack