Daniel Kulp wrote:
On Wednesday 09 April 2008, Florian Rosenberg wrote:
hi glen,

Glen Mazza wrote:
Server faults go into separate interceptor chains (second paragraph
of [1])--I have not done this before, but you should be able to
reuse the interceptors you have on your normal non-error chains for
the error situations.
so you mean the FAULT chain? i've added my interceptor everywhere but
AFAIR the fault chain interceptors are not invoked and all
interceptors in the IN chain stop after the READ phase (in case of the
server fault)

This is slightly changing in 2.0.6/2.1 as it may go a little bit furthur into the IN chain, but it won't go all the way. Basically, when a message comes in, it starts out on the IN chain. At some point along the chain (always was in the ReadHeadersInterceptor in 2.0.5, but will be furthur along in 2.0.6/2.1 in order to get ws-security to fully digest the whole body), it checks if the soap:body child is a soap:fault. If so, it stops the In chain and re-dispatches on the IN FAULT chain. Keep in mind, there are two fault chains. There is an OUT fault chain on the server and an IN fault chain on the client. Make sure you add to the right chain.

As I said, I've added my DummyInterceptor to every phase in every chain (IN, OUT, IN-FAULT, OUT-FAULT) but a service side exception does not go further than the IN_READ phase (where the handleMessage methods is invoked) then it stops processing the chains and I see an error from my JaxWsProxyFactoryBean in the client.

Any advise why the fault chain is not invoked? Below you find an sample main method that invokes an ErrorService with a buggyOperation() that always throws a custom exception (DummyException) and its output. The SimpleInterceptor just dumps each invocation of "handleMessage" and "handleFault" to the console.

I don't understand why the fault chain is never invoked in this case.
Any advise would be helpful how to configure/code this stuff correctly. I'm using the CXF 2.1 SNAPSHOT

-Florian


public static void main(String[] args) {
  ClientProxyFactoryBean factory = new JaxWsProxyFactoryBean();
  factory.setAddress("http://localhost:10000/ErrorService";);
  factory.setServiceClass(ErrorService.class);
  ErrorService ess = (ErrorService)factory.create();
                
  Client c = ClientProxy.getClient(ess);
  List<Interceptor> infault =  c.getInFaultInterceptors();
  infault.add(new SimpleInterceptor(Phase.RECEIVE));
  infault.add(new SimpleInterceptor(Phase.PRE_STREAM));
  infault.add(new SimpleInterceptor(Phase.PRE_PROTOCOL));
  infault.add(new SimpleInterceptor(Phase.UNMARSHAL));
  infault.add(new SimpleInterceptor(Phase.PRE_LOGICAL));
  infault.add(new SimpleInterceptor(Phase.PRE_INVOKE));
                
  List<Interceptor> in  = c.getInInterceptors();
  in.add(new SimpleInterceptor(Phase.RECEIVE));
  in.add(new SimpleInterceptor(Phase.PRE_STREAM));
  in.add(new SimpleInterceptor(Phase.PRE_PROTOCOL));
  in.add(new SimpleInterceptor(Phase.UNMARSHAL));
  in.add(new SimpleInterceptor(Phase.PRE_LOGICAL));
  in.add(new SimpleInterceptor(Phase.PRE_INVOKE));
                
  try {
   ess.buggyOperation("something wrong");
  } catch (DummyException_Exception e) {
    e.printStackTrace();
  }
}

Output:
----------------------------------
Apr 16, 2008 2:17:31 PM org.apache.cxf.bus.spring.BusApplicationContext getConfigResources
INFO: No cxf.xml configuration file detected, relying on defaults.
Apr 16, 2008 2:17:32 PM org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromClass INFO: Creating Service {http://services.quatsch/}ErrorServiceService from class quatsch.services.ErrorService
SimpleInterceptor::handleMessage() invoked in phase 'receive' invoked
SimpleInterceptor::handleMessage() invoked in phase 'pre-stream' invoked
SimpleInterceptor::handleMessage() invoked in phase 'pre-protocol' invoked
quatsch.services.DummyException_Exception: Error occured: something wrong
        at 
org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:184)
        at $Proxy37.buggyOperation(Unknown Source)
        at cxf.test.ErrorServiceClient.main(ErrorServiceClient.java:41)

Reply via email to