the client needs to disable setExceptionToBeThrownOnSOAPFault ServiceClient.setExceptionToBeThrownOnSOAPFault
now the client is free to handle any exception.. you will need to configure the client method to throw your exception which you can do at the phase level ConfigurationContext ctx=UtilServer.getConfigurationContext(); List phases_list=ctx.getAxisConfiguration().getInFlowPhases(); Phase phaseOne=(Phase) phases_list.get(0); //acquire the first phase phaseOne.addHandler(new FaultHandler()); Notice that the FaultHandler code has these 3 line which you can tweak to override the FaultHandler invoke(MsgContext msgContext) ..... org.apache.axiom.soap.SOAPFactory fac=msgContext.isSOAP11()? OMAbstractFactory.getSOAP11Factory() : OMAbstractFactory().getSOAP12Factory(); org.apache.axiom.soap.SOAPFaultCode PlaceNewLocalNameHere=fac.createSOAPFaultCode(); //override the value with whatever you need here assuming the new FaultCode overrides SOAPFaultCode msgContext.setProperty(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME,PlaceNewLocalNameHere); org.apache.axiom.soap.SOAPReasonName PlaceNewReasonHere=fac.createSOAPFaultReason(); ///override the reason with whatever you need here assuming the new ReasonName overrides SOAPReasonName msgContext.setProperty(SOAP12Constants.SOAP_FAULT_REASON_NAME,PlaceNewReasonHere); org.apache.axiom.soap.SOAPFaultDetail PlaceNewDetailHere=fac.createSOAPFaultDetail(); //override the PlaceNewDetailHere with whatever you need here assuming new SOAPFaultDetail overrides SOAPFaultDetail msgContext.setProperty(SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME,PlaceNewDetailHere); throw new FaultThatOverridesAxisFault("FaultThatOverridesAxisFaultException has occured); Greetings , Martin Gainty USCitizen(contractor) Please do not alter or disrupt this transmission. Thank You Date: Mon, 15 Feb 2010 09:04:08 -0500 Subject: Please help on Axis2 Exception handling From: lim...@gmail.com To: axis-user@ws.apache.org Dear All, I ran into a very weird problem with Axis2 exception handling, which puzzled me for long time. Any help from you Axis2 expert will be greately appreciated! This is what I did: 1. Get my service POJO ready. All method throws a customized MyException which is derived from java.lang.Exception2. Use Axis2 java2wsdl to convert this POJO to WSDL,. I can see the wsdl:fault part of each service call has been created successfully with name as MyException 3. Then use wsdl2java to generate client side API with ADB binding. Suddenly Axis2 creates a bunch of exception related classes, such as:MyExceptionExceptionMyExceptionExsd/MyException The methods will throw MyExceptionException, which contains MyExceptionE, which contains xsd/MyException. The xsd/MyException has all properties I defined at server side. Method also throw AxisFault. When I run the client code and throw MyException on server, at client side, I could only catch AxisFault exception which reason string as return of MyException.getMessage() defined on server. I could never catch MyException nor MyExceptionException at client side. This is the bigest issue that troubled me. If Axis2 has to wrap everything in AxisFault at client side, fine, but whey wsdl2java still throws MyExceptionException in generated code and never throw it? Thanks a lot! Li _________________________________________________________________ Hotmail: Trusted email with powerful SPAM protection. http://clk.atdmt.com/GBL/go/201469227/direct/01/