We are using jaws:client to consume a web service. We have inFaultInterceptor that captures soap faults for further processing. But this inFaultInterceptor is not being invoked for http errors like 404 or ConnectException. We configured interceptors to jaws:client. Can we write any interceptor that captures these http exceptions? Is there any better way to capture them? All we want is to take the control back when such exception/error occurrs. Note: we cannot catch them in web service code due to some restrictions.
You can use a FaultListener
added to CXF Bus
. The listener will capture the http exceptions allowing you to execute your code before they are raised to invoking method.
ClientProxy.getClient(jaxWSClientProxy).getBus().getProperties().put("org.apache.cxf.logging.FaultListener",new CxfFaultListenerImpl());
public class CxfFaultListenerImpl implements FaultListener{
public boolean faultOccurred(final Exception exception,final String description,final Message message) {
//return false to avoid standard CXF logging of exception
return false;
}
}