2

I'm currently using IBM Integration Bus v9 and I'm trying to get the DOM Node (org.w3c.dom.Node) from an aggregated message to unmarshall it into a Java Object.

In the first version of my flow, I was calling just one Web Service synchronously and, from a Java Compute Node, I was getting the DOM Document directly from the MbMessage and was unmarshalling the following way (source):

MbMessage inMessage = inAssembly.getMessage();
JAXBElement<BefpDocData> inMsgJavaObj = jaxbContext.createUnmarshaller().unmarshal(inMessage.getDOMDocument(), BefpDocData.class);
BefpDocData data = inMsgJavaObj.getValue();

The second version of my flow now calls two Web Services asynchronously and aggregate them with an AggregateReply node. In this case, I'm trying this way:

MbMessage inMessage = inAssembly.getMessage();
MbElement comIbmAggregateReplyBody = inMessage.getRootElement().getFirstElementByPath("/ComIbmAggregateReplyBody");
MbElement docGenBefa = comIbmAggregateReplyBody.getFirstElementByPath("/ComIbmAggregateReplyBody/DocGenBefa");
MbElement docGenBefaXML = docGenBefa.getLastChild();
Node docGenBefaNode = docGenBefaXML.getDOMNode();
JAXBElement<BefpDocData> inMsgJavaObj = jaxbContext.createUnmarshaller().unmarshal(docGenBefaNode, BefpDocData.class);
BefpDocData data = inMsgJavaObj.getValue();

My problem ist that the getDomNode always returns null despite the fact that the docGenBefaXML points on the XMLNSC part of the message. I tried to call the getDomNode method on various elements of the tree structure and it always returns null.

The structure of an aggregated message is described here.

Does anyone have any idea how to solve this ?

VincentS
  • 602
  • 1
  • 10
  • 24
  • Not sure. One theory ( and it's just a theory ) is that the getDOMNode() function does not work with aggregated messages. Might be worth checking the docs for getDOMNode(). If nothing comes up, open a PMR and ask IBM. – kimbert Mar 18 '16 at 08:55
  • Have you tried navigating to the reply root elements in DOM? That might work. – Attila Repasi Mar 18 '16 at 11:22

1 Answers1

2

Thanks for both comments, but I had to go one step deeper in the structure (down to the message body content) and it worked. But surprisingly, when I tried to display the node object in the debugger, it was also displayed as null.

In this case, if someone has to do the same, here is my code:

MbMessage inMessage = inAssembly.getMessage();
MbElement comIbmAggregateReplyBody = inMessage.getRootElement().getFirstElementByPath("/ComIbmAggregateReplyBody");
MbElement docGenBefa = comIbmAggregateReplyBody.getFirstElementByPath("/ComIbmAggregateReplyBody/DocGenBefa");
MbElement docGenBefaXML = docGenBefa.getLastChild();
MbElement docGenBefbDocData = docGenBefaXML.getLastChild();
Node docGenBefaNode = docGenBefbDocData.getDOMNode();
JAXBElement<BefpDocData> inMsgJavaObj = jaxbContext.createUnmarshaller().unmarshal(docGenBefaNode, BefpDocData.class);
BefpDocData data = inMsgJavaObj.getValue();
VincentS
  • 602
  • 1
  • 10
  • 24