Smooks: Outputting EDI from Java -


inspired proposed solution in smooks edi writer, have following java code:

// creates minimal edi message 1 field populated edifactv3d98amedpid edi = new edifactv3d98amedpid(); unbinterchangeheader header = new unbinterchangeheader(); unbinterchangeheader.s002senderidentification s002senderidentification = new unbinterchangeheader.s002senderidentification(); s002senderidentification.sete0004senderidentification("test"); header.sets002senderidentification(s002senderidentification); edi.setunbinterchangeheader(header);  smooks smooks = new smooks("edi-output-smooks-config.xml");  // sets access exports specified in smooks config executioncontext executioncontext = smooks.createexecutioncontext(); exports exports = exports.getexports(smooks.getapplicationcontext()); result[] results = exports.createresults();  smooks.filtersource(executioncontext, new javasource(edi), results);  list<object> objects = exports.extractresults(results, exports); javaresult.resultmap map = (javaresult.resultmap) objects.get(0);  d98ainterchangefactory factory = d98ainterchangefactory.getinstance(); unedifactinterchange41 unedifactinterchange = (unedifactinterchange41) map.get("unedifactinterchange");  // should output edi message string, stringwriter empty stringwriter edioutstream = new stringwriter(); factory.tounedifact(unedifactinterchange, edioutstream); 

... following smooks config:

<?xml version="1.0" encoding="utf-8"?> <smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"                   xmlns:core="http://www.milyn.org/xsd/smooks/smooks-core-1.4.xsd">      <!-- imports d98a edifact binding found in maven dependency -->     <import file="/org/milyn/edi/unedifact/d98a/message-bindingconfig.xml" />     <import file="/org/milyn/smooks/edi/unedifact/model/r41/bindings/unedifact-interchange.xml" />      <!-- configures result object accessing edi output -->     <core:exports>         <core:result type="org.milyn.payload.javaresult"/>     </core:exports>  </smooks-resource-list> 

the stringwriter returns empty string, whereas had hoped/expected java object edi string.

any suggestions or pointers?

i don't find classes edifactv3d98amedpid, unbinterchangeheade. made similar test:

unedifactinterchange41 edi = new unedifactinterchange41(); unb41 header = new unb41(); header.setsender(null); party sender = new party(); sender.setinternalid("test"); header.setsender(sender); edi.setinterchangeheader(header);  smooks smooks = new smooks("edi-output-smooks-config.xml");  executioncontext executioncontext = smooks.createexecutioncontext(); exports exports = exports.getexports(smooks.getapplicationcontext()); result[] results = exports.createresults();  smooks.filtersource(executioncontext, new javasource(edi), results);  list<object> objects = exports.extractresults(results, exports); javaresult.resultmap map = (javaresult.resultmap) objects.get(0);  d98ainterchangefactory factory = d98ainterchangefactory.getinstance(); unedifactinterchange41 u = (unedifactinterchange41) map.get("unedifactinterchange");  // should output edi message string, stringwriter empty stringwriter edioutstream1 = new stringwriter(); factory.tounedifact(u, edioutstream1); 

i had same result, empty string in end.

but think problem use of smooks. used smooks apache camel, don't know if correct way make transformation in smooks, think in case dont have call smook, input object edi , want print object in edi format.

the thing have is:

unedifactinterchange41 edi = new unedifactinterchange41(); unb41 header = new unb41(); header.setsender(null); party sender = new party(); sender.setinternalid("test"); header.setsender(sender); edi.setinterchangeheader(header);  d98ainterchangefactory factory = d98ainterchangefactory.getinstance();  stringwriter edioutstream1 = new stringwriter(); factory.tounedifact(edi, edioutstream1); 

i tested, , this:

unb++::test' 

i hope you


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -