m.put(Message.ENDPOINT_ADDRESS, currentURI.toString());
m.put(Message.REQUEST_URI, currentURI.toString());
m.put(Message.CONTENT_TYPE, headers.getFirst(HttpHeaders.CONTENT_TYPE));
Exchange exchange = new ExchangeImpl();
exchange.setSynchronous(true);
exchange.setOutMessage(m);
exchange.put(Bus.class, cfg.getBus());
exchange.put(MessageObserver.class, new ClientMessageObserver(cfg));
exchange.put(Endpoint.class, cfg.getConduitSelector().getEndpoint());
exchange.setOneWay("true".equals(headers.getFirst(Message.ONE_WAY_REQUEST)));
// no need for the underlying conduit to throw the IO exceptions in case of
// client requests returning error HTTP code, it can be overridden if really needed
exchange.put("org.apache.cxf.http.no_io_exceptions", true);
m.setExchange(exchange);
PhaseInterceptorChain chain = setupOutInterceptorChain(cfg);
m.setInterceptorChain(chain);
// context
if (cfg.getRequestContext().size() > 0 || cfg.getResponseContext().size() > 0) {
Map<String, Object> context = new HashMap<String, Object>();
context.put(REQUEST_CONTEXT, cfg.getRequestContext());
context.put(RESPONSE_CONTEXT, cfg.getResponseContext());
m.put(Message.INVOCATION_CONTEXT, context);
m.putAll(cfg.getRequestContext());
exchange.putAll(cfg.getRequestContext());
exchange.putAll(cfg.getResponseContext());
}
//setup conduit selector
prepareConduitSelector(m);
exchange.put(Service.class, cfg.getConduitSelector().getEndpoint().getService());
return m;
}