cxf interceptor intercept the request, but i can not find out the request params in the message

StackOverflow https://stackoverflow.com/questions/22167012

Domanda

My native language is not English and my English is poor,so I apologize if anything isn't clear. I have searched, but it did not help.
I have a web service using cxf framework, I want to use an interceptor to intercept the request which is passed by the service invoker. I can intercept the request but I can`t find out the request params.

  1. Here is my service interface:

    public int modCredenceForUser(@WebParam(name = "operatorId", mode = WebParam.Mode.IN) String operatorId,
                                      @WebParam(name = "userCredenceVO", mode = WebParam.Mode.IN) Holder<UserCredenceVO> userCredenceVO,
                                      @WebParam(name = "res", mode = WebParam.Mode.OUT) Holder<Response> res)
    
  2. Here is part of my service invoker code:

        userCredenceVO = new UserCredenceVO();
        ......
        ......
        Holder<UserCredenceVO> userCredenceVOHolder = new Holder<UserCredenceVO>(userCredenceVO);
        String operatorId = ServiceInvokeUtil.getOperatorId();
        int result = service.modCredenceForUser(operatorId, userCredenceVOHolder, res);
    
  3. Here is part of my service provider code:

    public class AuthenticationInterceptor extends
            AbstractPhaseInterceptor {
        public AuthenticationInterceptor(){
            super(Phase.RECEIVE);
        }
        /*
        @Override
        public void handleFault(Message message) {
            super.handleFault(message);
        }
        */
        public void handleMessage(Message message) {
            ......
            ......
        }
    
    }
    

I want to find out the request param "userCredenceVO", but how could I find it inthe message. This problem confused me a day, any help I would appreciate.

È stato utile?

Soluzione

The problem had been solved, the right codes as follows:

public class AuthenticationInterceptor extends
        AbstractPhaseInterceptor<SoapMessage> {

    public AuthenticationInterceptor(){
        super(Phase.PRE_INVOKE);
    }

    @Override
    public void handleFault(SoapMessage message) {
        super.handleFault(message);
    }

    @Override
    public void handleMessage(SoapMessage message) throws Fault {
        Set _set = message.getContentFormats();
        Iterator classIterator = _set.iterator();
        while (classIterator.hasNext()) {
            Class _class = (Class) classIterator.next();
            Object _obj = message.getContent(_class);
        }    
    }

}

The _obj contains the request params which is passed by service invoker.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top