0

I am using WID 8.5. I have two service message objects, which contain complex type array. I am trying to get these arrays into my java code and compare the values in both arrays. Based on the comparison, I have to create new array and store it into new service message object. I am getting these arrays using NodeList.

Please find the BO details here.

SMO1

&ltmetadata&gt
    &ltvalues&gt
        &ltdesc&gtclient country&lt/desc&gt
        &ltkey&gtIndia&ltkey&gt
    &ltvalues&gt
    &ltvalues&gt
        &ltdesc&gtclient name&lt/desc&gt
        &ltkey&gtSatish&ltkey&gt
    &ltvalues&gt
&ltmetadata&gt

SMO2 

&ltmetadata&gt
    &ltvalues&gt
        &ltdesc&gtclient name&lt/desc&gt
        &ltkey&gt123&ltkey&gt
    &ltvalues&gt
    &ltvalues&gt
        &ltdesc&gtclient country&lt/desc&gt
        &ltkey&gt124&ltkey&gt
    &ltvalues&gt
&ltmetadata&gt

Final SMO
&ltmetadata&gt
    &ltvalues&gt
        &ltdesc&gtclient name&lt/desc&gt
        &ltkey&gt123&ltkey&gt
        &ltvalues&gtSatish&lt/value&gt
    &lt/values&gt
    &ltvalues&gt
        &ltdesc&gtclient country&lt/desc&gt
        &ltkey&gt124&ltkey&gt
        &ltvalue&gtIndia&lt/value&gt
    &lt/values&gt
&ltmetadata&gt

Please provide me custom java code to accomplish this transformation.

ᄂ ᄀ
  • 5,669
  • 6
  • 43
  • 57
  • First -1, for directly asking the code and not the concept. Now having said that, parse both the XML in to corresponding DOM. On the first DOM get to the 'Client name' (getElementsByTag ...), on the second DOM again navigate to the 'Client name', additionally to the 'values' element (getParent ...). Import the first node into the second DOM, insert it as child to the 'values' element. Serialize the second DOM to file. – Ironluca Dec 12 '14 at 06:26
  • It's been a while since I've done something in WID, so I'll not give you straight answer, but in general you should use business object/ data object api to modify your object rather than xml apis (I'm assuming you are trying to do it in custom node in the flow). – Gas Dec 12 '14 at 10:42
  • Also you may have better luck in this forum [IBM Integration Designer and WebSphere Integration Developer](https://www.ibm.com/developerworks/community/forums/html/forum?id=11111111-0000-0000-0000-000000000821) – Gas Dec 12 '14 at 11:09
  • You need to generate DataObject model (add existing XSD Schema) for you XML and add it yo Java implementation for. You will have DataObject an access to SDO API. – Anton N Dec 12 '14 at 14:25

1 Answers1

0
  1. Get whatever elements you want using smo getter methods from smo1 and smo2 Ex:smo.getString(xpath of the smo)

  2. Build a data object with all the elements you got in the first step

  3. Add this data object to the Final smo

gitsitgo
  • 6,589
  • 3
  • 33
  • 45
krishna movva
  • 49
  • 2
  • 12