The whole stack trace should not bather you (unless from networking point of view) ,the calling code should parse the axis xml response and throw the exception just as you wish , so that you can display a simple string to the caller. This is right if you are using WSDL2Java to generate classes for the caller or if you are sharing classes with the caller and using proxy to invoke the service.
Ofer -----Original Message----- From: Vikas Phonsa [mailto:[EMAIL PROTECTED] Sent: Friday, June 18, 2004 10:37 PM To: '[EMAIL PROTECTED]' Subject: RE: exceptiong handling I pulled out the source code for samples/faults from the apache axis cvs and tried to implement and test the web service. Same thing, I get the stack trace back in the SOAP message. The SOAP message should just have the fault string like "no employee found". I don't want the entire big stack trace to come back to the client. And let me mention that I'm trying to run the webservice using axis under websphere v5.0. Exactly same thing happens even if I don't use axis. I'm enclosing excerpts from the wsdl generated for the code: <wsdl:message name="NoSuchEmployeeFault"> <wsdl:part name="fault" type="intf:NoSuchEmployeeFault"/> </wsdl:message> <wsdl:operation name="getEmployee" parameterOrder="id"> <wsdl:input message="intf:getEmployeeRequest" name="getEmployeeRequest"/> <wsdl:output message="intf:getEmployeeResponse" name="getEmployeeResponse"/> <wsdl:fault message="intf:NoSuchEmployeeFault" name="NoSuchEmployeeFault"/> </wsdl:operation> Vikas -----Original Message----- From: Davanum Srinivas [mailto:[EMAIL PROTECTED] Sent: Friday, June 18, 2004 9:28 AM To: [EMAIL PROTECTED] Subject: Re: exceptiong handling see samples/fault ----- Original Message ----- From: Vikas Phonsa <[EMAIL PROTECTED]> Date: Fri, 18 Jun 2004 08:44:48 -0700 Subject: RE: exceptiong handling To: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> Thanks for your reply. But shouldn't an application be allowed to throw any kind of custom exceptions not tied to Axis Fault ? And I would appreciate if someone can give a concrete working example of a web service class actually throwing an exception (extended from Axis fault or whatever). And also the wsdl for that web service. Thanks Vikas -----Original Message----- From: Dhanush Gopinath [mailto:[EMAIL PROTECTED] Sent: Thursday, June 17, 2004 10:27 PM To: [EMAIL PROTECTED] Subject: Re: exceptiong handling Vikas, I doubt that your excpetion class should extend AxisFault. But I am not sure about it , just have a hunch . Cheers Dhanush ----- Original Message ----- From: Vikas Phonsa To: '[EMAIL PROTECTED]' Sent: Friday, June 18, 2004 1:35 AM Subject: FW: exceptiong handling Hi This is not an axis specific issue but I would appreciate any help. I am using axis and am trying to implement exception handling functionality for my web service but I'm running into an issue. My Exception class is: ------------------------------------------------------------------------ ---- public class WebException extends Exception{ private String message; public WebException(String message){ this.message = message; } public String getMessage() { return this.message; } } And my web services implementation class is: public class ComSuzSiebelWebService { private ComSuzSiebelWebServicesBean bean = null; public void setBean(ComSuzSiebelWebServicesBean bean) throws Exception, WebException { this.bean = bean; if (bean.getAccountLocation() != "b"){ WebException e = new WebException("wrong value entered for account location"); throw e; } } } And in the wsdl I defined the fault as: <wsdl:message name="WebException"> <part name="message" type="xsd:string"/> </wsdl:message> <wsdl:portType> <wsdl:operation name="setBean" parameterOrder="bean"> <wsdl:input message="intf:setBeanRequest" name="setBeanRequest"/> <wsdl:output message="intf:setBeanResponse" name="setBeanResponse"/> <wsdl:fault name="fault" message="intf:WebException"/> </wsdl:operation> </wsdl:portType> But in the SOAP response message that I get back I'm getting the whole stack trace back - <soapenv:Fault> <faultcode xmlns:ns1="http://xml.apache.org/axis/">ns1:Server.userException</faultc ode> <faultstring> com.suz.siebel.webservice.WebException: wrong value entered for account location </faultstring> <detail> <ns2:stackTrace xmlns:ns2="http://xml.apache.org/axis/"> com.suz.siebel.webservice.WebException: wrong value entered for account location at com.suz.siebel.webservice.ComSuzSiebelWebService.setBean(ComSuzSiebelWeb Serv ice.java:37) at java.lang.reflect.Method.invoke(Native Method) at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java :372 ) at ----------------------- </ns2:stackTrace> </detail> </soapenv:Fault> My idea behind throwing the exception was to communicate back to the client that he has sent a wrong value for the "accountLocation" field of the bean that is sent to the setBean method. I don't want the whole stack trace to be sent back to the Client. Could you pls tell what am I doing wrong or if I am taking the wrong approach here. Thanks in advance. Vikas Phonsa ********************************************************* Disclaimer: This message (including any attachments) contains confidential information intended for a specific individual and purpose, and is protected by law. If you are not the intended recipient, you should delete this message and are hereby notified that any disclosure, copying, or distribution of this message, or the taking of any action based on it, is strictly prohibited. ********************************************************* Visit us at http://www.mahindrabt.com -- Davanum Srinivas - http://webservices.apache.org/~dims/
