cancel
Showing results for 
Search instead for 
Did you mean: 

Call GET RESTful service based on XML elements

markbernabe
Active Participant
0 Kudos

Hi Experts,

Say I have a sample input XML as below

<root>
	<element>http://www.foo.com/getStatus/1234</element>
	<element>http://www.foo.com/getStatus/4567</element>
	<element>http://www.foo.com/getStatus/8910</element>
<root>

In the iFlow, I need to traverse the XML, get all the values in each of the elements, use them as Address in the Receiver HTTP channel and trigger the service call.

So in the sample code, there has to be 3 GET web service calls.

For the response processing, I don't need to aggregate them. So I'm thinking of just writing each response for every call to the Data Store.

Is this feasible?

Thanks!

Accepted Solutions (0)

Answers (1)

Answers (1)

MortenWittrock
Active Contributor

Hi Mark

Your solution will look something like the following:

Set the Splitter (note that there is no Gather step) to split the input with XPath expression /root/element.

In the Content Modifier, create header CamelHttpUri, and set its value to the XPath expression /root/element. This will set the HTTP channel address for each iteration.

Finally, add whatever processing you need between the Request-Reply step and the End step.

Have fun 🙂

Regards,

Morten

markbernabe
Active Participant
0 Kudos

Hi Morten,

Right! After sleeping on this one over, I actually remembered multi mapping split in PI. So yeah will definitely try this one. Thanks!

MortenWittrock
Active Contributor
0 Kudos

No problem 🙂

markbernabe
Active Participant
0 Kudos

Hi Morten,

Can you confirm that when the 1st message after the General Splitter step (in my example, it is http://www.foo.com/getStatus/1234) fails/encounters an error, then the other messages (http://www.foo.com/getStatus/4567 and http://www.foo.com/getStatus/8910) will not be processed/shown in the trace?

MortenWittrock
Active Contributor

Hi Mark

You control this behaviour with the "Stop on Exception" property of the Splitter step. If checked, the subsequent messages will not be processed. If unchecked, they will be.

Regards,

Morten

markbernabe
Active Participant
0 Kudos

Got it. Thanks Morten!