Skip to Content
0

Call GET RESTful service based on XML elements

Jan 24, 2017 at 04:04 AM

156

avatar image

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!

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Morten Wittrock
Jan 24, 2017 at 10:40 PM
1

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


iflow.png (20.4 kB)
Show 5 Share
10 |10000 characters needed characters left characters exceeded

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!

0

No problem :)

0

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?

0

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

1

Got it. Thanks Morten!

0