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 -----
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</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(ComSuzSiebelWebService.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

Reply via email to