-
1. Re: Throwing user defined exception
macberry Aug 27, 2003 4:31 AM (in response to cazacov)You don't need to do anything particular... You just throw an exception in the method of your bean and you catch (or except or whatever language you use) it on the client side...
You don't need to declare anything in the web-service.xml. -
2. Re: Throwing user defined exception
cazacov Aug 27, 2003 6:12 AM (in response to cazacov)I create my own exception:
class MyException extends Exception {
public MyException(String str) {
super(str);
}
...
Then create some test bean that throws this exception:
public String sayHello()
throws test.MyException
{
throw new test.MyException("Some text");
}
When I try to call sayHello method from my Delphi client, in JBoss console I see long exception stack trace:
13:50:36,913 ERROR [AxisServlet] Exception:
AxisFault
faultCode: {http://xml.apache.org/axis/}Server.userException
faultString: java.lang.reflect.InvocationTargetException
faultActor: null
faultDetail:
stackTrace: java.lang.reflect.InvocationTargetException
...
Client receives long XML document with all this stack trace lines. At the end there is some useful info:
...
Caused by: java.lang.IllegalAccessError: tried to access class test.MyException from class $Proxy119
at $Proxy119.sayHello(Unknown Source)
... 52 more
</ns2:stackTrace>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
So, on client side I can extract type of user exception, but server sends very long document instead of short answer that exception was thrown and saves stack trace in server.log file.
It looks like critical situation. Ok, server continues to process my queries and client got some information, but the way I do it now does not look nice.