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 Vikas Phonsa <VP...@suz.com> on 2004/06/17 20:49:21 UTC

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 

 

  

 
<http://localhost:1994/wsexplorer/wsdl/soap_envelope_xml.jsp?soapEnvelopeTyp
e=1##> -        <soapenv:Fault>

                  <faultcode
xmlns:ns1="http://xml.apache.org/axis/">ns1:Server.userException</faultcode>

                  <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(ComSuzSiebelWebServ
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