return handleException(oneWay,
SOAPMessages.MESSAGES.operationNotAvailableTarget(firstBodyElement.toString(), _service.getName() + "'."));
}
try {
SynchronousInOutHandler inOutHandler = new SynchronousInOutHandler();
Exchange exchange = _service.createExchange(operationName, inOutHandler);
// identify ourselves
exchange.getContext().setProperty(ExchangeCompletionEvent.GATEWAY_NAME, _gatewayName, Scope.EXCHANGE)
.addLabels(BehaviorLabel.TRANSIENT.label());
SOAPBindingData soapBindingData = new SOAPBindingData(soapMessage, wsContext);
// add any thread-local and/or binding-extracted credentials
SecurityContext securityContext = _securityContextManager.getContext(exchange);
securityContext.getCredentials().addAll(credentials);
securityContext.getCredentials().addAll(soapBindingData.extractCredentials());
_securityContextManager.setContext(exchange, securityContext);
Message message;
try {
message = _messageComposer.compose(soapBindingData, exchange);
} catch (Exception e) {
throw e instanceof SOAPException ? (SOAPException)e : new SOAPException(e);
}
// Do not perfom this check if the message has been unwrapped
if (!_unwrapped) {
assertComposedMessageOK(message, operation);
}
exchange.getContext(message).setProperty(MESSAGE_NAME, operation.getInput().getMessage().getQName().getLocalPart());
if (oneWay) {
exchange.send(message);
if (exchange.getState().equals(ExchangeState.FAULT)) {
return composeResponse(exchange, msgContext, operation, true);
} else {
return null;
}
} else {
exchange.send(message);
try {
exchange = inOutHandler.waitForOut(_waitTimeout);
} catch (DeliveryException e) {
return handleException(oneWay,
SOAPMessages.MESSAGES.timedOut(String.valueOf(_waitTimeout),
_service.getName().toString()));
}