NormalizedMessage nm = me.createMessage();
me.setMessage(nm, "in");
nm.setContent(inputSource);
boolean res = channel.sendSync(me);
if (!res) {
throw new ActionSystemException("Timeout on sending message");
}
if (me.getStatus() == ExchangeStatus.ACTIVE) {
if (me.getFault() != null) {
Document fault;
try {
fault = transformer.toDOMDocument(me.getFault());
me.setStatus(ExchangeStatus.DONE);
} catch (Exception e) {
me.setError(e);
throw new ActionSystemException(e);
} finally {
channel.send(me);
}
Element e = fault.getDocumentElement();
// Try to determine fault name
String faultName = e.getLocalName();
String partName = BPEComponent.PART_PAYLOAD;
QName elemName = new QName(e.getNamespaceURI(), e.getLocalName());
if (wsdlOperation != null) {
for (Iterator itFault = wsdlOperation.getFaults().values().iterator(); itFault.hasNext();) {
Fault f = (Fault) itFault.next();
Part p = (Part) f.getMessage().getParts().values().iterator().next();
if (elemName.equals(p.getTypeName())) {
faultName = f.getName();
partName = p.getName();
}
}
}
BPRuntimeException bpre = new BPRuntimeException(faultName, "");
bpre.setNameSpace(e.getNamespaceURI());
/* We must use a type that implements BPE's IFormattableValue interface
* since otherwise the value will get wrapped in a CannedFormattableValue
* which has undesireable side effects.
*/
DocumentFormattableValue documentFormattableValue = new DocumentFormattableValue(fault);
bpre.addPartMessage(partName, documentFormattableValue);
throw bpre;
} else {
try {
nm = me.getMessage("out");
if (nm != null) {
/* We must use a type that implements BPE's IFormattableValue interface
* since otherwise the value will get wrapped in a CannedFormattableValue
* which has undesireable side effects.
*/
Document out = transformer.toDOMDocument(nm);
DocumentFormattableValue documentFormattableValue = new DocumentFormattableValue(out);
output.put(outputPartName, documentFormattableValue);
}
me.setStatus(ExchangeStatus.DONE);
} catch (Exception e) {
me.setError(e);
throw new ActionSystemException(e);
} finally {
channel.send(me);
}
}
} else if (me.getStatus() == ExchangeStatus.ERROR) {
// Extract error
Exception error = me.getError();
throw new BPRuntimeException("Unknown", error);
}
} catch (MessagingException e) {
throw new ActionSystemException(e);
}
if (LOG.isDebugEnabled()) {
LOG.debug("Request: " + payload);
LOG.debug("Response: " + output.get(outputPartName));
}