0

I have an xml similar to the following which has some element composed by an url. That url is another webservice which contains another xml. What I need to do is completing my xml with information from the webservice, and I would like to achieve that with camel. Here goes the example:

Initial xml

<root>
    <level11>Level1.txt</level1>
    <level12>
        <level21>http://someservice/11</level21>
        <level21>http://someservice/12</level21>
    </level12>
    <level13>
        <level22>http://someservice/21</level22>
        <level22>http://someservice/22</level22>
    </level13>
</root>

http://someservice is returning an xml which i have to replace into original xml. For example

http://someservice/11 returns

<someservice>
    <test>11</test>
</someservice>

http://someservice/12 returns

<someservice>
    <test>12</test>
</someservice>

http://someservice/21 returns

<someservice>
    <test>21</test>
</someservice>

http://someservice/22 returns

<someservice>
    <test>22</test>
</someservice>

my final xml would be:

<root>
    <level11>Level1.txt</level1>
    <level12>
        <level21>
            <someservice>
                <test>11</test>
            </someservice>
        </level21>
        <level21>
            <someservice>
                <test>12</test>
            </someservice>
        </level21>
    </level12>
    <level13>
        <level22>
            <someservice>
                <test>21</test>
            </someservice>
        </level22>
        <level22>
            <someservice>
                <test>22</test>
            </someservice>
        </level22>
    </level13>
</root>

So my question is what is the best pattern I should use to achieve this result?

Ben ODay
  • 20,784
  • 9
  • 45
  • 68
ddelizia
  • 1,571
  • 5
  • 30
  • 54

1 Answers1

1

This seems to fit the content enrichment EIP. This EIP will allow you to append and expand you original message based on the output of other services. See more about this at the Apache Camel site by reading the Content Enrichment EIP documentation.

Namphibian
  • 12,046
  • 7
  • 46
  • 76