Hi,
I use:
public class MyServiceException extends org.apache.axis.AxisFault
implements java.io.Serializable {}
On the server side, I call
public void setFaultCodeAsString(java.lang.String code)
to set faultcode before I return exception to client.
In client side faultcode is used to determine the error. It worked fine with
this way.
john
-----Original Message-----
From: Vikas Phonsa [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 18, 2004 4:52 PM
To: '[EMAIL PROTECTED]'
Subject: RE: Help in Exception handling...
Christophe,
I am doing the exact same thing. Can u post a sample soap message returned
to the client when an exception has been thrown by the web service.
When I throw an exception after setting its method to a relevant value, I
also get the stack trace in my SOAP message. I just want the message.
Vikas
-----Original Message-----
From: Christophe Roudet [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 18, 2004 2:40 PM
To: [EMAIL PROTECTED]
Subject: RE: Help in Exception handling...
I was only able to have exceptions extending RemoteException to be
deserialized correctly (not as an AxisFault).
Here is the way I do it:
In the wsdl I have,
In types:
<complexType name="MyException">
<sequence>
<element name="cause" nillable="true" type="xsd:anyType"/>
<element name="message" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
<wsdl:message name="MyException">
<wsdl:part name="fault" type="tns:MyException"/>
</wsdl:message>
In portType:
<wsdl:operation name="myop"
...
<wsdl:fault message="impl:MyException" name="MyException"/>
</wsdl:operation>
Java side:
public class MyException extends RemoteException implements Serializable {
private String _mess;
// ==============
// Constructors
// ==============
public MyException() {
super();
}
public MyException(String message) {
super(message);
}
Public MyException(Throwable e) {
super(e.getMessage());
super.initCause(e);
}
// ================
// Public methods
// ================
// no setter method in RemoteException, needed for Soap.
public void setMessage(String mess) {
_mess = mess;
}
// overrides the RemoteException method.
public String getMessage() {
return (_mess == null) ? super.getMessage() : _mess;
}
}
Christophe
> -----Original Message-----
> From: matthew.hawthorne [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, August 18, 2004 4:42 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Help in Exception handling...
>
> Ragunath Marudhachalam wrote:
> > Is it possible to throw an exception that extends java.lang.Excpetion
> from a
> > webservice. I found some material that throws AxisFault exception. Also
> i
> > read it is possible to throw an exception which has getter and setter
> > methods. Any example and tips from anyone who has already worked on
> would be
> > really helpful.
>
> I would really like to find an answer for this also. I've been trying
> to figure it out, off and on, for
> months.
>
> I've looked through the documentation, and there just isn't anything
> definite with regard to
> exception handling. I've tried adding beanMappings for my exceptions
> but nothing seems
> to happen.
>
> Can anyone point me to a through explanation of
> AxisFaults, custom Exceptions, RemoteException, how it works with
> Call.invoke vs. remote stubs, etc... ?
>
> Thanks!