protected void invokeInboundChain(Exchange ex, Endpoint ep) { Message m = getInBoundMessage(ex); Message inMsg = ep.getBinding().createMessage(); MessageImpl.copyContent(m, inMsg); // Copy Response Context to Client inBound Message // TODO a Context Filter Strategy required. inMsg.putAll(m); inMsg.put(Message.REQUESTOR_ROLE, Boolean.TRUE); inMsg.put(Message.INBOUND_MESSAGE, Boolean.TRUE); inMsg.setExchange(ex); Exception exc = inMsg.getContent(Exception.class); if (exc != null) { ex.setInFaultMessage(inMsg); ColocInFaultObserver observer = new ColocInFaultObserver(bus); observer.onMessage(inMsg); } else { // Handle Response ex.setInMessage(inMsg); PhaseManager pm = bus.getExtension(PhaseManager.class); SortedSet<Phase> phases = new TreeSet<Phase>(pm.getInPhases()); ColocUtil.setPhases(phases, Phase.USER_LOGICAL, Phase.PRE_INVOKE); InterceptorChain chain = ColocUtil.getInInterceptorChain(ex, phases); inMsg.setInterceptorChain(chain); chain.doIntercept(inMsg); } ex.put(ClientImpl.FINISHED, Boolean.TRUE); }
protected Message createMessage( Object body, String httpMethod, MultivaluedMap<String, String> headers, URI currentURI, Exchange exchange, Map<String, Object> invocationContext, boolean proxy) { Message m = cfg.getConduitSelector().getEndpoint().getBinding().createMessage(); m.put(Message.REQUESTOR_ROLE, Boolean.TRUE); m.put(Message.INBOUND_MESSAGE, Boolean.FALSE); m.put(Message.HTTP_REQUEST_METHOD, httpMethod); m.put(Message.PROTOCOL_HEADERS, headers); if (currentURI.isAbsolute() && currentURI.getScheme().startsWith(HTTP_SCHEME)) { m.put(Message.ENDPOINT_ADDRESS, currentURI.toString()); } else { m.put(Message.ENDPOINT_ADDRESS, state.getBaseURI().toString()); } Object requestURIProperty = cfg.getRequestContext().get(Message.REQUEST_URI); if (requestURIProperty == null) { m.put(Message.REQUEST_URI, currentURI.toString()); } else { m.put(Message.REQUEST_URI, requestURIProperty.toString()); } m.put(Message.CONTENT_TYPE, headers.getFirst(HttpHeaders.CONTENT_TYPE)); body = checkIfBodyEmpty(body); setEmptyRequestPropertyIfNeeded(m, body); m.setContent(List.class, getContentsList(body)); m.put(URITemplate.TEMPLATE_PARAMETERS, getState().getTemplates()); PhaseInterceptorChain chain = setupOutInterceptorChain(cfg); chain.setFaultObserver(setupInFaultObserver(cfg)); m.setInterceptorChain(chain); exchange = createExchange(m, exchange); exchange.put(Message.REST_MESSAGE, Boolean.TRUE); exchange.setOneWay("true".equals(headers.getFirst(Message.ONE_WAY_REQUEST))); exchange.put(Retryable.class, new RetryableImpl()); // context setContexts(m, exchange, invocationContext, proxy); // setup conduit selector prepareConduitSelector(m, currentURI, proxy); return m; }
private void handleAbort(SoapMessage message, MessageContext context) { if (isRequestor(message)) { // client side outbound if (getInvoker(message).isOutbound()) { message.getInterceptorChain().abort(); MessageObserver observer = (MessageObserver) message.getExchange().get(MessageObserver.class); if (!message.getExchange().isOneWay() && observer != null) { Endpoint e = message.getExchange().get(Endpoint.class); Message responseMsg = e.getBinding().createMessage(); // the request message becomes the response message message.getExchange().setInMessage(responseMsg); SOAPMessage soapMessage = ((SOAPMessageContext) context).getMessage(); if (soapMessage != null) { responseMsg.setContent(SOAPMessage.class, soapMessage); XMLStreamReader xmlReader = createXMLStreamReaderFromSOAPMessage(soapMessage); responseMsg.setContent(XMLStreamReader.class, xmlReader); } responseMsg.put( PhaseInterceptorChain.STARTING_AT_INTERCEPTOR_ID, SOAPHandlerInterceptor.class.getName()); observer.onMessage(responseMsg); } // We dont call onCompletion here, as onCompletion will be called by inbound // LogicalHandlerInterceptor } else { // client side inbound - Normal handler message processing // stops, but the inbound interceptor chain still continues, dispatch the message // By onCompletion here, we can skip following Logical handlers onCompletion(message); } } else { if (!getInvoker(message).isOutbound()) { // server side inbound message.getInterceptorChain().abort(); Endpoint e = message.getExchange().get(Endpoint.class); Message responseMsg = e.getBinding().createMessage(); if (!message.getExchange().isOneWay()) { message.getExchange().setOutMessage(responseMsg); SOAPMessage soapMessage = ((SOAPMessageContext) context).getMessage(); responseMsg.setContent(SOAPMessage.class, soapMessage); InterceptorChain chain = OutgoingChainInterceptor.getOutInterceptorChain(message.getExchange()); responseMsg.setInterceptorChain(chain); // so the idea of starting interceptor chain from any // specified point does not work // well for outbound case, as many outbound interceptors // have their ending interceptors. // For example, we can not skip MessageSenderInterceptor. chain.doInterceptStartingAfter( responseMsg, SoapPreProtocolOutInterceptor.class.getName()); } } else { // server side outbound - Normal handler message processing // stops, but still continue the outbound interceptor chain, dispatch the message } } }