You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Ragunath Marudhachalam <rm...@circuitvision.com> on 2004/08/18 21:14:11 UTC
Help in Exception handling...
Hello ALL,
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.
Thanks
Ragu
Re: Help in Exception handling...
Posted by "matthew.hawthorne" <ma...@apache.org>.
Ragunath Marudhachalam wrote:
> I tried customizing exceptions and i had .net on the client. All i can do on
> the client side is, i can catch the exception as SoapException and get the
> string from that exception. .net client could not build a class for the
> custom exceptions in the web reference like it does for all other objects
> that is passed and returned as parameters.
That makes sense. I'm under the assumption that a custom Java exception on
the server can't be instantiated in a client written in another
language. I'm OK
with that.
My problem is, I have a Java server and Java client, and my custom exception
is not being instantiated in the client. Instead, an AxisFault is
created that
*looks* just like my exception, but isn't. This means that if I print
the exception,
it looks OK, but it won't go into the expected catch blocks. I also
can't pass
custom data (like an Object array, or Integer, etc.) in an exception
from server to
client, which is my real goal.
Any ideas, anyone?
RE: Help in Exception handling...
Posted by Ragunath Marudhachalam <rm...@circuitvision.com>.
I tried customizing exceptions and i had .net on the client. All i can do on
the client side is, i can catch the exception as SoapException and get the
string from that exception. .net client could not build a class for the
custom exceptions in the web reference like it does for all other objects
that is passed and returned as parameters.
Thanks
Ragu
-----Original Message-----
From: matthew.hawthorne [mailto:matth@apache.org]
Sent: Friday, August 20, 2004 12:01 PM
To: axis-user@ws.apache.org
Subject: Re: Help in Exception handling...
I read the article at
http://www-106.ibm.com/developerworks/xml/library/ws-tip-jaxrpc.html
and made some customizations to my exceptions accordingly. The SOAP
looks correct,
but I just cannot get Axis to instantiate the exceptions on the client
side. They are always
returned as Axis faults.
I've got the beanMappings set on the client side too, does anyone else
have any suggestions?
Is there a class that I can set the DEBUG log level on to see what the
problem is? I'd almost
rather have it fail than return AxisFaults all the time, it would make
things easier to debug.
Thanks!
Re: Help in Exception handling...
Posted by "matthew.hawthorne" <ma...@apache.org>.
I read the article at
http://www-106.ibm.com/developerworks/xml/library/ws-tip-jaxrpc.html
and made some customizations to my exceptions accordingly. The SOAP
looks correct,
but I just cannot get Axis to instantiate the exceptions on the client
side. They are always
returned as Axis faults.
I've got the beanMappings set on the client side too, does anyone else
have any suggestions?
Is there a class that I can set the DEBUG log level on to see what the
problem is? I'd almost
rather have it fail than return AxisFaults all the time, it would make
things easier to debug.
Thanks!
RE: Help in Exception handling...
Posted by Christophe Roudet <cr...@activia.net>.
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!
Re: Help in Exception handling...
Posted by "matthew.hawthorne" <ma...@apache.org>.
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!