Hi ALL,

I'm using CXf's fault out interceptor to intercept the exception from the
web services method. That works fine within the handleMessage method.. Now I
have two queries,

1. How do I had extra information to the Fault object apart from setting the
faultcode.?
2. Say if there is any error in the handleMessage method, the control goes
to handleFault method but in the handle fault method it simply unwinds and
logs something like - *GetMth has thrown exception, unwinding now:
java.lang.Exception:*. But the fault message(in xml format) is not being
sent to the client as Output mesasage, How do I make sure that the fault
message is sent as SOAPfault  to the clinet?
[in the hanldeMessage bleow, i have place *f=null *to introduce the fault ]

Handle message and handleFault methods:


         *public class SimpleSOAPFaultInterceptor extends
AbstractSoapInterceptor {
        private static Logger log = Logger.getLogger("org.apache");
        
        public SimpleSOAPFaultInterceptor() {
                super(Phase.MARSHAL);
        }
        
        public void handleMessage(SoapMessage message) throws Fault {
                // TODO Auto-generated method stub
                try {
                
                        Fault f = (Fault) message.getContent(Exception.class);
                        //f=null; /[Introduing an excpetion so that handleFault 
is called]/             
log.debug(" f ::::: "+ f.getCode());
                        Throwable cause = f.getCause();
                        if (cause instanceof MyServiceException) {
                                f.setFaultCode(new QName("", 
String.valueOf("100000")));
                        } else {
                                log.warn("!!!!!!Unexpected Exception thrown ", 
cause);
                        }
                        } catch (SOAPException e) {
                                // TODO Auto-generated catch block
                                System.out.println("CAUGHT HERE "+e);
                                e.printStackTrace();
                        }  catch (Exception e) {
                                // TODO Auto-generated catch block
                                System.out.println("CAUGHT HERE Exception "+e);
                                throw new Fault(new Exception(
                        "Exception...."));
                        }
        }
        
        
        
        @Override
        public void handleFault(SoapMessage message) {
                // TODO Auto-generated method stub
                super.handleFault(message);
                
                System.out.println("**handleFault the message ** "+message);
                Fault f = (Fault) message.getContent(Exception.class);
                System.out.println("**the f ** "+f);
            //f.setFaultCode(new QName("", String.valueOf("8")));
                //SoapFault sf = new SoapFault("message",new QName("",
String.valueOf("99000")));
                //SoapFault.createFault(f, message.getVersion())
            //                   .setMessage("INSIDE DIUDE");
                
        }*



--
View this message in context: 
http://cxf.547215.n5.nabble.com/HandleFault-in-CXF-tp5735813.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to