axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christophe Roudet" <crou...@activia.net>
Subject RE: Help in Exception handling...
Date Wed, 18 Aug 2004 21:39:36 GMT
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:matth@apache.org]
> Sent: Wednesday, August 18, 2004 4:42 PM
> To: axis-user@ws.apache.org
> 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!




Mime
View raw message