Return-Path: Delivered-To: apmail-xml-axis-user-archive@xml.apache.org Received: (qmail 59349 invoked by uid 500); 26 Jul 2002 12:05:49 -0000 Mailing-List: contact axis-user-help@xml.apache.org; run by ezmlm Precedence: bulk Reply-To: axis-user@xml.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list axis-user@xml.apache.org Received: (qmail 59340 invoked from network); 26 Jul 2002 12:05:49 -0000 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-MimeOLE: Produced By Microsoft Exchange V6.0.5762.3 Subject: Catching the correct Exception in an Axis client when namespace-mapping is different than server. (WAS: RE: service specific exception - HOWTO?) Date: Fri, 26 Jul 2002 14:05:48 +0200 Message-ID: <89F2D7244FA78A48B8AD71BBC76E6734877F7F@bra-no-24-001.corp.bravida.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: service specific exception - HOWTO? Thread-Index: AcIzMvTM371ouoMcSsuwB+r0JroJ0wBZvzcQ From: To: X-OriginalArrivalTime: 26 Jul 2002 12:05:48.0528 (UTC) FILETIME=[C76F0700:01C2349C] X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Status: O X-Status: X-Keywords: X-UID: 820 I have a problem with catching the correct Exception on my Axis client, = I am just getting exceptions of type AxisFault. The reason for this is = probably that I change the package name of the Exception on the server = side, but not on the client side. Thus I am creating a name-mismatch = between the Exception in the server code and the Exception in the client = code. Can this be fixed? (I don't want to change the package names, the = server-side classes generated by Axis must be in another = package-structure than the default.) A more detailed explanation: An Exception is thrown at an Axis service and sent to the client as e.g. no.geomatikk.soap.axis.NoAccess= Exception I have a problem with this, because when generating my server-side Axis = code, I don't use the default package names, I spesify to change some = package names like this: java org.apache.axis.wsdl.WSDL2Java -v -s -d Application = -f..\build\NStoPkg.properties = ..\..\geomatikk.jar-addon\deploy\PoiAccess.wsdl Where one of the entries in my file "..\build\NStoPkg.properties" is: http\://soap.geomatikk.no=3Dno.geomatikk.soap.axis When I am generating the client-side code, I am using the DEFAULT = namespace-to-java package mapping, so the Exception class generated on = my client side (with wsdl2java) is of the type = no.geomatikk.soap.NoAccessException. I am wondering if there is a way to change/map the exception name on the = server side so that it would (correctly) send no.geomatikk.soap.NoAccessExcep= tion Maby this should be done automatically, and is a bug in Axis? Any help would be greatly appreciated! Eirik Wahl Bravida Geomatikk AS -----Original Message----- From: Robert Herold [mailto:herold@cotagesoft.com] Sent: 24. juli 2002 18:56 To: axis-user@xml.apache.org Cc: tomj@macromedia.com Subject: RE: service specific exception - HOWTO? Tom, thanks for your reply. The exception class is available on the = client side, but it still is not getting thrown. Does my exception have to extend RemoteException? AxisFault? To demonstrate that the class is available, I modifed the test code to construct a dummy instance of the exception (and I also removed the = message from the exception class): public class BobHExceptionTest { public static void main(String[] args) { BobHException proveIt =3D new BobHException(); try { BobH b =3D new BobHServiceLocator().getBobH(); b.throwException(); } catch (BobHException be) { System.out.println("got it"); System.out.println("exception class name is " + be.getClass().getName()); } catch (org.apache.axis.AxisFault af) { System.out.println("Hmmm, got AxisFault"); } catch (Exception e) { System.out.println("Didn't get it"); System.out.println("exception class name is " + e.getClass().getName()); } } } -----Original Message----- From: axis-user-return-5670-herold=3Dcotagesoft.com@xml.apache.org [mailto:axis-user-return-5670-herold=3Dcotagesoft.com@xml.apache.org]On Behalf Of Tom Jordahl Sent: Wednesday, July 24, 2002 9:15 AM To: 'axis-user@xml.apache.org' Subject: RE: service specific exception - HOWTO? Robert, This should work as the exception class is getting passed in the faultDetails: com.cotagesoft.test.webservices.bobh.BobHException Do you have this class available on the client side? If not, Axis will = just create an AxisFault instead of a fault of this class. NOTE: We currently do not pass along the exception data ("psycho = monkey"). -- Tom Jordahl Macromedia -----Original Message----- From: Robert Herold [mailto:herold@cotagesoft.com] Sent: Tuesday, July 23, 2002 7:20 PM To: axis-user@xml.apache.org Subject: service specific exception - HOWTO? How do I make a service that throws a service-specific exception, and = make a java client that can catch that exception? I wrote a very simple test case (see below). The fault transmitted on = the wire seems to be OK (see response, captured by TCPMon, at the end of = this message), but the axis client code does not throw my service specific exception - it only throws an AxisFault. Has anyone been able to do this? If so, how? The details: I am using Tomcat 4.0.4, Axis Beta 3 on Windows XP. I compiled the interface, then ran java2wsdl to get the wsdl, then wsdl2java to get the client stub/service/servicelocator classes. The service is very simple: public interface BobH extends java.rmi.Remote { public void throwException() throws BobHException,java.rmi.RemoteException; } and public class BobHSoapBindingImpl implements BobH { public void throwException() throws BobHException { throw new BobHException("psycho monkey"); } } and public class BobHException extends Exception { public BobHException (String msg) { super(msg); } } On the client side: public class BobHExceptionTest { public static void main(String[] args) { try { BobH b =3D new BobHServiceLocator().getBobH(); b.throwException(); } catch (BobHException be) { System.out.println("got it, msg is " + be.getMessage()); System.out.println("exception class name is " + be.getClass().getName()); } catch (Exception e) { System.out.println("Didn't get it"); System.out.println("exception class name is " + e.getClass().getName()); } } } Running this, I get: - Mapping Exception to AxisFault AxisFault faultCode: {http://xml.apache.org/axis/}Server.generalException faultString: psycho monkey faultActor: null faultDetail: exceptionName: = com.cotagesoft.test.webservices.bobh.BobHException stackTrace: AxisFault faultCode: {http://xml.apache.org/axis/}Server.generalException faultString: psycho monkey faultActor: null faultDetail: exceptionName: = com.cotagesoft.test.webservices.bobh.BobHException psycho monkey at com.cotagesoft.test.webservices.bobh.BobHSoapBindingImpl.throwExcepti on(BobHSoapBindingImpl.java:87) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. ### rest of stack trace omitted ### psycho monkey at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder. java:135) ### more omitted stack trace ### at org.apache.axis.client.Call.invoke(Call.java:1251) at com.cotagesoft.test.webservices.bobh.BobHSoapBindingStub.throwExcepti on(BobHSoapBindingStub.java:121) at com.cotagesoft.test.webservices.bobh.BobHExceptionTest.main(BobHExcep tionTest.java:27) Didn't get it exception class name is org.apache.axis.AxisFault The generated WSDL is: The response, captured by TCPMon, is: HTTP/1.1 500 Internal Server Error Content-Type: text/xml; charset=3Dutf-8 Connection: close Date: Tue, 23 Jul 2002 22:54:56 GMT Server: Apache Tomcat/4.0.4 (HTTP/1.1 Connector) ns1:Server.generalException psycho monkey com.cotagesoft.test.webservices= .bobh .BobHException AxisFault faultCode: {http://xml.apache.org/axis/}Server.generalException faultString: psycho monkey faultActor: null faultDetail: exceptionName: com.cotagesoft.test.webservices.bobh.BobHException psycho monkey at com.cotagesoft.test.webservices.bobh.BobHSoapBindingImpl.throwException(B= obH SoapBindingImpl.java:87) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ### more omitted stack trace ### at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1= 125 ) at java.lang.Thread.run(Thread.java:536) ---------- Robert Herold Cotagesoft, Inc. 650 474 9013 x808