*
* @param input the HTTP request message
* @return the HTTP response message from invocation
*/
public HttpResponseBindingData invoke(final HttpRequestBindingData input) {
HttpResponseBindingData response = null;
try {
SynchronousInOutHandler inOutHandler = new SynchronousInOutHandler();
Exchange exchange = _serviceRef.createExchange(getOperationName(input), inOutHandler);
// identify ourselves
exchange.getContext().setProperty(ExchangeCompletionEvent.GATEWAY_NAME, _gatewayName, Scope.EXCHANGE)
.addLabels(BehaviorLabel.TRANSIENT.label());
Message message = _messageComposer.compose(input, exchange);
_securityContextManager.addCredentials(exchange, input.extractCredentials());
if (exchange.getContract().getConsumerOperation().getExchangePattern() == ExchangePattern.IN_ONLY) {
exchange.send(message);
if (exchange.getState().equals(ExchangeState.FAULT)) {
response = (HttpResponseBindingData) _messageComposer.decompose(exchange, new HttpResponseBindingData());
} else {
response = new HttpResponseBindingData();
}
} else {
exchange.send(message);
exchange = inOutHandler.waitForOut();
response = (HttpResponseBindingData) _messageComposer.decompose(exchange, new HttpResponseBindingData());
}
} catch (Exception e) {
HttpLogger.ROOT_LOGGER.unexpectedExceptionInvokingSwitchyardServcie(e);
}
return response;