}
protected Map<String, Object> prepareRequest(Exchange camelExchange, org.apache.cxf.message.Exchange cxfExchange) throws Exception {
// create invocation context
WrappedMessageContext requestContext = new WrappedMessageContext(
new HashMap<String, Object>(), null, Scope.APPLICATION);
camelExchange.setProperty(Message.MTOM_ENABLED, String.valueOf(endpoint.isMtomEnabled()));
// set data format mode in exchange
DataFormat dataFormat = endpoint.getDataFormat();
camelExchange.setProperty(CxfConstants.DATA_FORMAT_PROPERTY, dataFormat);
LOG.trace("Set Camel Exchange property: {}={}", DataFormat.class.getName(), dataFormat);
// set data format mode in the request context
requestContext.put(DataFormat.class.getName(), dataFormat);
// don't let CXF ClientImpl close the input stream
if (dataFormat == DataFormat.MESSAGE) {
cxfExchange.put(Client.KEEP_CONDUIT_ALIVE, true);
LOG.trace("Set CXF Exchange property: {}={}", Client.KEEP_CONDUIT_ALIVE, true);
}
// bind the request CXF exchange
endpoint.getCxfBinding().populateCxfRequestFromExchange(cxfExchange, camelExchange,
requestContext);
// Remove protocol headers from scopes. Otherwise, response headers can be
// overwritten by request headers when SOAPHandlerInterceptor tries to create
// a wrapped message context by the copyScoped() method.
requestContext.getScopes().remove(Message.PROTOCOL_HEADERS);
return requestContext.getWrappedMap();
}