Smooks unedifact JavaResult Bean is null

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Smooks unedifact JavaResult Bean is null

ponderMuse
I am currently testing the use of the Smooks API with Unedifact mapping/binding jars for parsing Edifact messages into XML and POJOs.

In my test code, when I parse Edi messages into XML, I get the XML output for the given Edifact messages as expected (when passing StreamResult(writer) instance to smooks.filterSource()). However, when I try to parse the same Edi messages into POJOs (using JavaResult instance), I only seem to get null beans out of it.

Test Code:

UNEdifactReaderConfigurator readerConfig =
new UNEdifactReaderConfigurator("urn:org.milyn.edi.unedifact:d04a-mapping:*");

File edi = new File("test-data.edi");
assertTrue(edi.exists());

InputStream is = new FileInputStream(edi);
assertNotNull(is);

JavaResult result = new JavaResult();

Smooks smooks = new Smooks();
smooks.setReaderConfig(readerConfig);
smooks.filterSource(new StreamSource(is), result);

Cusdec cusdec = (Cusdec) result.getBean("cusdec");
assertNotNull(cusdec);


Debugging shows that cusdec object is null and result object displays the following content

interchangeDelimiters:
<org.milyn.edisax.model.internal.Delimiters>
  <segment>'</segment>
  <field>+</field>
  <component>:</component>
  <escape>?</escape>
  <decimalSeparator>.</decimalSeparator>
  <segmentDelimiter>'</segmentDelimiter>
  <ignoreCRLF>false</ignoreCRLF>
  <delimiterChars class="linked-hash-set">
    <char>'</char>
    <char>+</char>
    <char>:</char>
    <char>?</char>
  </delimiterChars>
</org.milyn.edisax.model.internal.Delimiters>

PTIME:
<null/>

PUUID:
<null/>


I was expecting the result object to contain something like

cusdec:
<org.milyn.edi.unedifact.d04a.CUSDEC.Cusdec>
..
</org.milyn.edi.unedifact.d04a.CUSDEC.Cusdec>

Any ideas why this might be?

Cheers, PM.
Reply | Threaded
Open this post in threaded view
|

Re: Smooks unedifact JavaResult Bean is null

ponderMuse
This post was updated on .
I was able to solve the problem by adding the Cusdec's bindingconfig.xml binding configuration to the smooks instance's setup (See edited code above). However, if we are parsing different message types, then each type's binding config needs to be added. Not sure if this is the correct way of setting up smooks for this scenario.

The binding configuration for d04a's Cusdec was included by adding the following two lines of code:

InputStream cis = DataParserTest.class.getResourceAsStream(
"/org/milyn/edi/unedifact/d04a/CUSCAR/bindingconfig.xml");


smooks.addConfigurations(cis);