// Unwrap the first two levels, to remove the part wrapper
Node node=WSDLHelper.unwrapMessagePart(mesg);
// Need to create an exchange
SynchronousInOutHandler rh = new SynchronousInOutHandler();
Exchange exchange=_serviceReference.createExchange(operationName, rh);
Message req = exchange.createMessage();
req.setContent(node);
if (headers != null) {
for (Map.Entry<String, Object> e : headers.entrySet()) {
exchange.getContext(req).setProperty(e.getKey(), headers.get(e.getKey())).addLabels(EndpointLabel.SOAP.label());
}
// Clear the headers in preparation for response headers
headers.clear();
}
exchange.send(req);
try {
exchange = rh.waitForOut(_waitTimeout);
} catch (DeliveryException e) {
throw BPELMessages.MESSAGES.timedOutAfterMsWaitingOnSynchronousResponseFromTargetService(_waitTimeout, _serviceReference.getName().toString());
}
Message resp=exchange.getMessage();
if (resp == null) {
throw BPELMessages.MESSAGES.responseNotReturnedFromOperationOnService(operationName, _serviceReference.getName().toString());
}
// Process header values associated with the response
for (org.switchyard.Property p : exchange.getContext().getProperties(Scope.MESSAGE)) {
if (p.hasLabel(EndpointLabel.SOAP.label())) {
headers.put(p.getName(), p.getValue());
}
}
// Check for exception - but don't rethrow a BPEL
// fault as it will be converted to a message
// response
if (resp.getContent() instanceof Exception
&& !(resp.getContent() instanceof BPELFault)) {
throw (Exception)resp.getContent();
}
Element respelem=(Element)resp.getContent(Node.class);
javax.wsdl.Operation operation=_portType.getOperation(operationName, null, null);
if (exchange.getState() == ExchangeState.FAULT) {
QName faultCode=null;
if (respelem instanceof SOAPFault) {
SOAPFault fault=(SOAPFault)respelem;