SOAPMessage request;
Boolean oneWay = false;
String action = null;
try {
request = _messageComposer.decompose(exchange, new SOAPBindingData(SOAPUtil.createMessage(_bindingId))).getSOAPMessage();
QName firstBodyElement = SOAPUtil.getFirstBodyElement(request);
action = WSDLUtil.getSoapAction(_wsdlPort, firstBodyElement, _documentStyle);
oneWay = WSDLUtil.isOneWay(_wsdlPort, firstBodyElement, _documentStyle);
if (_feature.isAddressingEnabled()) {
Context context = exchange.getContext();
_dispatcher.getRequestContext().put(SOAPUtil.SWITCHYARD_CONTEXT, context);
// It is a one way if a replyto address is set
String toAddress = SOAPUtil.getToAddress(exchange.getContext());
if (toAddress != null) {
_dispatcher.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, toAddress);
}
}
} catch (Exception e) {
throw e instanceof SOAPException ? (SOAPException)e : new SOAPException(e);
}
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Outbound ---> Request:[" + _referenceName + "][" + SOAPUtil.soapMessageToString(request) + "]" + (oneWay ? " oneWay " : ""));
}
SOAPMessage response = invokeService(request, oneWay, action);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Outbound <--- Response:[" + _referenceName + "][" + SOAPUtil.soapMessageToString(response) + "]");
}
if (response != null) {
// This property vanishes once message composer processes this message
// so caching it here
Boolean hasFault = response.getSOAPBody().hasFault();
Message message;
try {
SOAPBindingData bindingData = new SOAPBindingData(response);
if (hasFault) {
SOAPFaultInfo faultInfo = new SOAPFaultInfo();
faultInfo.copyFaultInfo(response);
bindingData.setSOAPFaultInfo(faultInfo);
}
Integer status = (Integer)_dispatcher.getResponseContext().get(MessageContext.HTTP_RESPONSE_CODE);
if (status != null) {
bindingData.setStatus(status);
}
message = _messageComposer.compose(bindingData, exchange);
} catch (Exception e) {
throw e instanceof SOAPException ? (SOAPException)e : new SOAPException(e);
}