StAXUtils.createXMLStreamReader(new ByteArrayInputStream(soap.getBytes()));
StAXBuilder builder = new StAXSOAPModelBuilder(xmlReader);
OMElement elem = builder.getDocumentElement();
elem.build();
if (elem instanceof SOAPEnvelope) {
SOAPEnvelope soapEnvelope = (SOAPEnvelope) elem;
String soapNamespace = soapEnvelope.getNamespace().getNamespaceURI();
if (soapEnvelope.getHeader() == null) {
SOAPFactory soapFactory;
if (soapNamespace.equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
soapFactory = OMAbstractFactory.getSOAP12Factory();
} else {
soapFactory = OMAbstractFactory.getSOAP11Factory();
}
soapFactory.createSOAPHeader(soapEnvelope);
}
sourceNodeList.add(soapEnvelope);
} else {
sourceNodeList.add(elem);
}
} catch (XMLStreamException e) {
synLog.error("Source Property cannot be parsed : " + e.getStackTrace().toString());
}
} else if (o instanceof ArrayList) {
ArrayList nodesList = (ArrayList) o;
for (Object node : nodesList) {
if (node instanceof OMElement) {
if (node instanceof SOAPEnvelope) {
SOAPEnvelope soapEnvelope = (SOAPEnvelope) node;
String soapNamespace = null;
if (soapEnvelope.getNamespace() != null) {
soapNamespace = soapEnvelope.getNamespace().getNamespaceURI();
}
if (soapEnvelope.getHeader() == null && soapNamespace != null) {
SOAPFactory soapFactory;
if (soapNamespace.equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
soapFactory = OMAbstractFactory.getSOAP12Factory();
} else {
soapFactory = OMAbstractFactory.getSOAP11Factory();
}
soapFactory.createSOAPHeader(soapEnvelope);
}
sourceNodeList.add(soapEnvelope);
} else {
OMElement ele = (OMElement) node;
sourceNodeList.add(ele);
}
} else if (node instanceof OMText) {
sourceNodeList.add((OMText) node);
}
}
} else {
synLog.error("Invalid source property type.");
}
} else if (sourceType == EnrichMediator.INLINE) {
if (inlineOMNode instanceof OMElement) {
OMElement inlineOMElement = (OMElement) inlineOMNode;
if (inlineOMElement.getQName().getLocalPart().equals("Envelope")) {
SOAPEnvelope soapEnvelope = getSOAPEnvFromOM(inlineOMElement);
if (soapEnvelope != null) {
sourceNodeList.add(soapEnvelope);
} else {
synLog.error("Inline Source is not a valid SOAPEnvelope.");
}
} else {
sourceNodeList.add(inlineOMElement.cloneOMElement());
}
} else if (inlineOMNode instanceof OMText) {
sourceNodeList.add(inlineOMNode);
} else if (inlineKey != null) {
Object inlineObj = synCtx.getEntry(inlineKey);
if (inlineObj instanceof OMElement) {
if (((OMElement) inlineObj).getQName().getLocalPart().equals("Envelope")) {
SOAPEnvelope soapEnvelope = getSOAPEnvFromOM((OMElement) inlineObj);
if (soapEnvelope != null) {
sourceNodeList.add(soapEnvelope);
} else {
synLog.error("Specified Resource as Source is not a valid SOAPEnvelope.");
}