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 Matthias Brunner <mb...@blumenstrasse.vol.at> on 2002/07/19 13:36:41 UTC

Error reporting

Hello!

Can anyone recommend a way to implement error reporting?

For example, when I use "call.invoke(args)", a java.rmi.RemoteException  is 
thrown regardless of whether the connection could not even be established 
(java.net.ConnectionException)  or there was an exception thrown at server 
side (NullPointerException, for instance)
Both result in the same faultCode (when downcasted to AxisFault): 
({http://xml.apache.org/axis/}Server.userException)
The only way to tell the difference is by parsing faultString. Is there a 
better solution to this problem?

Ideally, one should be able to throw MyException on server side and catch the 
exception on client side. How could this be achieved?

What other possibilities are there to distinguish between errors?
-- 
Matthias Brunner <mb...@blumenstrasse.vol.at>
PGP FP 7862 32B3 3B75 292A F76F  5042 8587 21AB 5B89 D501
Check out http://blumenstrasse.vol.at/~mb/gpgkey.asc


Re: Error reporting

Posted by Steve Loughran <st...@iseran.com>.
----- Original Message -----
From: "Jesse D. Sightler" <js...@eximtechnologies.com>
To: <ax...@xml.apache.org>
Sent: Friday, July 19, 2002 10:03 AM
Subject: Re: Error reporting


> The relevant section from the User Guide appears to be:
>
> [Begin Quote]
> Exceptions are represented as wsdl:fault elements
> 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. The fields in the object must be of the datatypes that can be
> reliably mapped into WSDL.
>
> If your exception meet 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.
>
> Again, to be sure of interoperability, you need to be experiment a bit.
> Remember, the calling language may not have the notion of Exceptions, or
> at least not be as rigorous as Java in the rules as to how exceptions
> must be handled.
> [End Quote]

I wrote that bit by looking at the JAX-RPC spec, not the implementation, so
remember, it may not be true :)

> I am truly curious... has anyone experimented with this to see if it
> will allow Java AXIS clients to use normal try...catch blocks to catch
> customer Exception classes?

I am throwing simple Exceptions and it does seem to work. hook into a
RemoteException and you can catch transport events, normal exceptos for
things you throw yourself.

public void doSomething(string param) throws Exception {
    ...
}

1. I havent tried sending my own exceptions back
2. I havent run the wsdl through WSDL.exe to see what C# makes of it.






Re: Error reporting

Posted by "Jesse D. Sightler" <js...@eximtechnologies.com>.
The relevant section from the User Guide appears to be:

[Begin Quote]
Exceptions are represented as wsdl:fault elements
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. The fields in the object must be of the datatypes that can be
reliably mapped into WSDL.

If your exception meet 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.

Again, to be sure of interoperability, you need to be experiment a bit.
Remember, the calling language may not have the notion of Exceptions, or
at least not be as rigorous as Java in the rules as to how exceptions
must be handled. 
[End Quote]


I am truly curious... has anyone experimented with this to see if it
will allow Java AXIS clients to use normal try...catch blocks to catch
customer Exception classes?

And does this interoperate with any other implementations (esp. C#)?  It
would be very useful if it did.

I wish that this area of SOAP had better documentation, as it seems
noone is very clear on what a proper implementation would do.

---
Jess



On Fri, 2002-07-19 at 12:53, Steve Loughran wrote:
> 
> ----- Original Message -----
> From: "Matthias Brunner" <mb...@blumenstrasse.vol.at>
> To: <ax...@xml.apache.org>
> Sent: Friday, July 19, 2002 4:36 AM
> Subject: Error reporting
> 
> 
> Hello!
> 
> >Ideally, one should be able to throw MyException on server side and catch
> the
> >exception on client side. How could this be achieved?
> 
> read the JAX-RPC spec on exceptions; there is now a quick summary of it in
> the CVS version of the axis user guide/
> 
> If your method says it throws MyException then it will get sent back as a
> WSDL fault, not a soap fault. The wsdl will describe your exception class,
> which should have getters for every attribute, and a constructor that takes
> every attribute as named arguments.
> 
> No, I dont know what the interop implications are



Re: Error reporting

Posted by Steve Loughran <st...@iseran.com>.
----- Original Message -----
From: "Matthias Brunner" <mb...@blumenstrasse.vol.at>
To: <ax...@xml.apache.org>
Sent: Friday, July 19, 2002 4:36 AM
Subject: Error reporting


Hello!

>Ideally, one should be able to throw MyException on server side and catch
the
>exception on client side. How could this be achieved?

read the JAX-RPC spec on exceptions; there is now a quick summary of it in
the CVS version of the axis user guide/

If your method says it throws MyException then it will get sent back as a
WSDL fault, not a soap fault. The wsdl will describe your exception class,
which should have getters for every attribute, and a constructor that takes
every attribute as named arguments.

No, I dont know what the interop implications are