// get CXF binding
CxfEndpoint endpoint = (CxfEndpoint)getEndpoint();
CxfBinding binding = endpoint.getCxfBinding();
// create invocation context
WrappedMessageContext requestContext = new WrappedMessageContext(
new HashMap<String, Object>(), null, Scope.APPLICATION);
Map<String, Object> responseContext = new HashMap<String, Object>();
// set data format mode in exchange
DataFormat dataFormat = endpoint.getDataFormat();
camelExchange.setProperty(CxfConstants.DATA_FORMAT_PROPERTY, dataFormat);
if (LOG.isTraceEnabled()) {
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);
if (LOG.isTraceEnabled()) {
LOG.trace("Set CXF Exchange property: " + Client.KEEP_CONDUIT_ALIVE
+ "=" + true);
}
}
// get binding operation info
BindingOperationInfo boi = getBindingOperationInfo(camelExchange);
ObjectHelper.notNull(boi, "BindingOperationInfo");
// keep the message wrapper in PAYLOAD mode
if (dataFormat == DataFormat.PAYLOAD && boi.isUnwrapped()) {
boi = boi.getWrappedOperation();
cxfExchange.put(BindingOperationInfo.class, boi);
}
// store the original boi in the exchange
camelExchange.setProperty(BindingOperationInfo.class.getName(), boi);
if (LOG.isTraceEnabled()) {
LOG.trace("Set exchange property: BindingOperationInfo: " + boi);
}
// Unwrap boi before passing it to make a client call
if (dataFormat != DataFormat.PAYLOAD && !endpoint.isWrapped() && boi != null) {
if (boi.isUnwrappedCapable()) {
boi = boi.getUnwrappedOperation();
if (LOG.isTraceEnabled()) {
LOG.trace("Unwrapped BOI " + boi);
}
}
}
// bind the request CXF exchange
binding.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);
Map<String, Object> invocationContext = new HashMap<String, Object>();
invocationContext.put(Client.RESPONSE_CONTEXT, responseContext);
invocationContext.put(Client.REQUEST_CONTEXT, requestContext.getWrappedMap());
// send the CXF request
client.invoke(boi, getParams(endpoint, camelExchange),
invocationContext, cxfExchange);