if (ex == null) {
ex = new ExchangeImpl();
exchange.setExchange(ex);
}
assert ex != null;
InvokingContext invokingContext = ex.get(InvokingContext.class);
if (invokingContext == null) {
invokingContext = InvokingContextFactory.createContext(dataFormat);
ex.put(InvokingContext.class, invokingContext);
}
Map params = invokingContext.getRequestContent(inMessage);
// invoke the stream message with the exchange context
CxfClient cxfClient = (CxfClient)client;
// need to get the binding object to create the message
BindingOperationInfo boi = ex.get(BindingOperationInfo.class);
Message response = null;
if (boi == null) {
// it should be the raw message
response = new MessageImpl();
} else {
// create the message here
Endpoint ep = ex.get(Endpoint.class);
response = ep.getBinding().createMessage();
}
response.setExchange(ex);
// invoke the message prepare the context
Map<String, Object> context = new HashMap<String, Object>();
Map<String, Object> requestContext = new HashMap<String, Object>();
Map<String, Object> responseContext = new HashMap<String, Object>();
// TODO Get the requestContext from the CamelExchange
context.put(CxfClient.REQUEST_CONTEXT, requestContext);
context.put(CxfClient.RESPONSE_CONTEXT, responseContext);
try {
Object result = cxfClient.dispatch(params, context, ex);
ex.setOutMessage(response);
invokingContext.setResponseContent(response, result);
// copy the response context to the response
response.putAll(responseContext);
cxfBinding.storeCxfResponse(exchange, response);
} catch (Exception e) {
response.setContent(Exception.class, e);