spring integration - How to store payload and append it to another payload later? -
i using spring integration in project. have following payload.
<?xml version="1.0" encoding="utf-8"?> <pq> <pqcontact> <hostaddress>10.193.244.136</hostaddress> </pqcontact> <workflowstatuscomment> <comment>i here</comment> </workflowstatuscomment> </pq>
i want extract tag <workflowstatuscomment>
i.e workflowstatuscomment <comment>i here</comment></workflowstatuscomment>
, save future purpose. don't want use java code use saved tag info in future. want add saved info payload @ end of execution.i know header enrichers, don't know how use saved header enriched values without using java. have use spring integration components manipulate payload.
the second payload going append saved tag info here:
<?xml version="1.0" encoding="utf-8"?> <pq> <pqcontact> <hostaddress>10.193.244.136</hostaddress> <name>ashok</name> <userid>007</userid> </pqcontact> </pq>
after appending saved tag info above payload, final payload should initial payload information. below:
<?xml version="1.0" encoding="utf-8"?> <pq> <pqcontact> <hostaddress>10.193.244.136</hostaddress> <name>ashok</name> <userid>007</userid> </pqcontact> <workflowstatuscomment> <comment>i here</comment> </workflowstatuscomment> </pq>
is there way?
you can extract info xml using <int-xml:xpath-transformer>
or #xpath()
spel-function.
but have share "another payload" , how add extracted.
maybe better have solution java , consider here how convert spring integration xml dsl or similar.
please, revise question make more clearer.
update
to insert 1 xml have fight bit javax.xml
api.
the code might this:
documentbuilder builder = documentbuilderfactory.newinstance().newdocumentbuilder(); document target = builder.parse(new stringbufferinputstream(targetxml)); element source = builder.parse(new stringbufferinputstream(sourcexml)).getdocumentelement(); target.appendchild(source);
update 2
but don't want use java code.
well, if target xml can represent template string can use standard replacefirst()
in <transformer>
expression
:
string targetxml = "";
<transformer expression="'<?xml version="1.0" encoding="utf-8"?> <pq> <pqcontact> <hostaddress>10.193.244.136</hostaddress> <name>ashok</name> <userid>007</userid> </pqcontact> $workflowstatuscommenttoken$ </pq>'.replacefirst('\\$workflowstatuscommenttoken\\$', headers.originalxml)"/>
Comments
Post a Comment