newCtx.setProperty(
EIPConstants.MESSAGE_SEQUENCE,
msgNumber + EIPConstants.MESSAGE_SEQUENCE_DELEMITER + msgCount);
// get a clone of the envelope to be attached
SOAPEnvelope newEnvelope = MessageHelper.cloneSOAPEnvelope(envelope);
// if payload should be preserved then attach the iteration element to the
// node specified by the attachPath
if (preservePayload) {
Object attachElem = attachPath.evaluate(newEnvelope);
if (attachElem != null &&
attachElem instanceof List && !((List) attachElem).isEmpty()) {
attachElem = ((List) attachElem).get(0);
}
// for the moment attaching element should be an OMElement
if (attachElem != null && attachElem instanceof OMElement) {
((OMElement) attachElem).addChild(o);
} else {
handleException("Error in attaching the splitted elements :: " +
"Unable to get the attach path specified by the expression " +
attachPath, synCtx);
}
} else if (newEnvelope.getBody() != null) {
// if not preserve payload then attach the iteration element to the body
newEnvelope.getBody().addChild(o);
}
// set the envelope and mediate as specified in the target
newCtx.setEnvelope(newEnvelope);