Convert DFDL to XML

1.5k Views Asked by At

I'm trying to parse a web service response message in the following format (message tree):

Message
    Properties
            Properties..[]
    DFDL
            ObjectIWantUnmarshalled
                    AllItsDataIwant[]

And unmarshal the "ObjectIWantUnmarshalled". However, this data is in DFDL format. In my request, I use the following line in order to format from XML to DFDL:

Document outDocument = outMessage.createDOMDocument(MbDFDL.PARSER_NAME);

But there doesn't seem to be a way to to the opposite, of DFDL to XML. I have tried:

Document outDocument = inMessage.createDOMDocument(MbXMLNSC.PARSER_NAME);

As well as other attempts to simply unmarshal the data directly from the MbMessage:

jaxbContext_COBOL.createUnmarshaller().unmarshal(inMessage.getDOMDocument())

But I have not been able to get a Document node this way, or any other way, it is always null.

1

There are 1 best solutions below

1
On

Probably a lot too late, but you were going about this the wrong way.

When using WMB and IIB you should use the built-in XML support - not the javax.XML.* class library. So instead of using the JAXB unmarshaller, you should

  • create an XMLNSC tree under the output message root
  • copy the input DFDL message tree to the output XMLNSC message tree ( one line )

...and the message flow will serialize ( unmarshall ) the tree as XML whenever it needs to - when it encounters an output node, or when you call outMessage.toBitstream().