### Question:
ServiceInvokerInterceptor extends AbstractPhaseInterceptor<Message> { public void handleMessage(final Message message) { final Exchange exchange = message.getExchange(); final Endpoint endpoint = exchange.getEndpoint(); final Service service = endpoint.getService(); final Invoker invoker = service.getInvoker(); Runnable invocation = new Runnable() { public void run() { Exchange runableEx = message.getExchange(); Object result = invoker.invoke(runableEx, getInvokee(message)); if (!exchange.isOneWay()) { Endpoint ep = exchange.getEndpoint(); Message outMessage = runableEx.getOutMessage(); if (outMessage == null) { outMessage = new MessageImpl(16, 1); outMessage.setExchange(exchange); outMessage = ep.getBinding().createMessage(outMessage); exchange.setOutMessage(outMessage); } copyJaxwsProperties(message, outMessage); if (result != null) { MessageContentsList resList = null; if (result instanceof MessageContentsList) { resList = (MessageContentsList)result; } else if (result instanceof List) { resList = new MessageContentsList((List<?>)result); } else if (result.getClass().isArray()) { resList = new MessageContentsList((Object[])result); } else { outMessage.setContent(Object.class, result); } if (resList != null) { outMessage.setContent(List.class, resList); } } } } }; Executor executor = getExecutor(endpoint); Executor executor2 = exchange.get(Executor.class); if (executor2 == executor || executor == null || !(message.getInterceptorChain() instanceof PhaseInterceptorChain)) { invocation.run(); } else { exchange.put(Executor.class, executor); final PhaseInterceptorChain chain = (PhaseInterceptorChain)message.getInterceptorChain(); final AtomicBoolean contextSwitched = new AtomicBoolean(); final FutureTask<Object> o = new FutureTask<Object>(invocation, null) { @Override protected void done() { super.done(); if (contextSwitched.get()) { PhaseInterceptorChain.setCurrentMessage(chain, null); message.remove(Message.THREAD_CONTEXT_SWITCHED); } chain.releaseChain(); } @Override public void run() { if (PhaseInterceptorChain.setCurrentMessage(chain, message)) { contextSwitched.set(true); message.put(Message.THREAD_CONTEXT_SWITCHED, true); } synchronized (chain) { super.run(); } } }; synchronized (chain) { executor.execute(o); chain.releaseAndAcquireChain(); } try { o.get(); } catch (InterruptedException e) { throw new Fault(e); } catch (ExecutionException e) { if (e.getCause() instanceof RuntimeException) { throw (RuntimeException)e.getCause(); } throw new Fault(e.getCause()); } } } ServiceInvokerInterceptor(); void handleMessage(final Message message);  }### Answer:
@Test public void testInterceptor() throws Exception { ServiceInvokerInterceptor intc = new ServiceInvokerInterceptor(); MessageImpl m = new MessageImpl(); Exchange exchange = new ExchangeImpl(); m.setExchange(exchange); exchange.setInMessage(m); exchange.setOutMessage(new MessageImpl()); TestInvoker i = new TestInvoker(); Endpoint endpoint = createEndpoint(i); exchange.put(Endpoint.class, endpoint); Object input = new Object(); List<Object> lst = new ArrayList<>(); lst.add(input); m.setContent(List.class, lst); intc.handleMessage(m); assertTrue(i.invoked); List<?> list = exchange.getOutMessage().getContent(List.class); assertEquals(input, list.get(0)); }