@Override @SuppressWarnings("rawtypes") public void handleMessage(Message message) throws Fault { if (binding != null) { Exchange ex = message.getExchange(); if (ex.get(HandlerChainInvoker.class) == null) { List<Handler> hc = binding.getHandlerChain(); if (hc.size() > 1) { //no need to sort etc if the chain is empty or has one handler only Collections.sort(hc, comparator); //install a new HandlerChainInvoker using the sorted handler chain; //the AbstractJAXWSHandlerInterceptor will be using this invoker //instead of creating a new one ex.put(HandlerChainInvoker.class, new HandlerChainInvoker(hc, isOutbound(message, ex))); } } } }
protected void setupClient(Object obj, Class<?> seiClass, WebServiceFeature... features) { Binding binding = ((BindingProvider)obj).getBinding(); Client client = obj instanceof DispatchImpl<?> ? ((DispatchImpl<?>)obj).getClient() : ClientProxy.getClient(obj); ClientConfig config = readConfig(seiClass); if (config != null) { CXFClientConfigurer helper = new CXFClientConfigurer(); helper.setupConfigHandlers(binding, config); helper.setConfigProperties(client, config.getProperties()); } client.getOutInterceptors().add(new HandlerChainSortInterceptor(binding)); //add this *after* the config has been set (if any)! if (features != null) { for (WebServiceFeature f : features) { if (f instanceof AbstractClientFeature) { ((AbstractClientFeature)f).initialize(obj); } } } }