简体   繁体   中英

Apache CXF Service: How to configure Handler Chain without @HandlerChain annotation?

I tried following code:

Resolver Class:

public class WorkdayHandlerResolver implements HandlerResolver {

    private List<Handler> handlerChain = new ArrayList<Handler>();

    public WorkdayHandlerResolver(){
         this.handlerChain.add( new WorkdayHandler() );
    }

    @Override
    public List<Handler> getHandlerChain(PortInfo portInfo) {
      return this.handlerChain;
    }
}

Handler Class:

public class WorkdayHandler implements SOAPHandler<SOAPMessageContext>{
    private static final Logger LOGGER = LoggerFactory.getLogger(WorkdayHandler.class.getName());


    @Override
    public boolean handleMessage(SOAPMessageContext context) {

Main Service Class:

HumanResourcesService humanResourcesService = new HumanResourcesService();
HumanResourcesPort humanPort = humanResourcesService.getHumanResources();
humanResourcesService.setHandlerResolver(new WorkdayHandlerResolver());

When executed the same in server. It does not show any request or response.

Could anyone please help me how to configure handler chain without @Handlerchain annotation as no implementable example or sureshot example i am getting on google?

I removed

humanResourcesService.setHandlerResolver(new WorkdayHandlerResolver());

and places following line

((BindingProvider)humanPort).getBinding().setHandlerChain(Collections.singletonList(new WorkdayHandler()));

and it was fixed

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM