Hi,

I'd like to have a single Interceptor for in & outbound messages. My goal is to 
add a little statistic info. When was the web service called how long did it 
take to process it and so on.

I read in the archive how to do this:
http://cxf.547215.n5.nabble.com/Around-interceptor-td560176.html#a560176

But this does not seem to work anymore with the current release.
Because the exchange is null when the message is inbound.

Here a little code to illustrate my problem.


private OutboundInterceptor out = new OutboundInterceptor();

  public StatisticsInterceptor() {
                super(Phase.READ);
                addAfter(ReadHeadersInterceptor.class.getName());
        }

  public void handleMessage(SoapMessage message) throws Fault {
      
        Exchange ex = message.getExchange();
        ex.getOutMessage().getInterceptorChain().add(out);

        if (message.getVersion() instanceof Soap11) {
        Map<String, List<String>> headers = CastUtils.cast((Map)
         message.get(Message.PROTOCOL_HEADERS));
        
       if (headers != null) {
        List<String> sa = headers.get("SOAPAction");
        if (sa != null && sa.size() > 0) {
        System.out.println("soap action " + sa.get(0));
                                }
                        }
                }
        }

        static class OutboundInterceptor extends AbstractSoapInterceptor {
                public OutboundInterceptor() {
                        super(Phase.MARSHAL_ENDING);
                        addAfter(BareOutInterceptor.class.getName());
                }

       public void handleMessage(SoapMessage message) throws Fault {
                        System.out.println("Outbound Interceptor!");
                }
        }

Cheers,
Pete
-- 
GMX DSL SOMMER-SPECIAL: Surf & Phone Flat 16.000 für nur 19,99 Euro/mtl.!*
http://portal.gmx.net/de/go/dsl

Reply via email to