One Star

Loop through tSOAP components

Hi,
I am trying to create a Talend job, that requires a lot of SOAP calls. I need to use a tSOAP using an ID (within the message bosy) to fetch a response, that I am using to iterate over XPath (tExtractXML). This response may contain more IDs, which I should use to further call the same tSOAP.
An example,
tSOAP calls first time by supplying an ID = 1. The response returned consists of two further IDs (under certain XPath) say ID = 2 and ID = 3. Now I want to iterate over the same tSOAP using ID = 2. This may further return an ID = 4. So essentially, then for ID = 3, tSOAP should be called, and if no further XPath is present then ID = 4 and so on..
I am stuck at how to proceed. Should I go with ArrayList? Or should I store them in a XML file, and just provide a Loop query?
Further, once I retrieve all these IDs, I need to call tSOAPs (different) again, to fetch further responses, so I need this list of IDs somehow.
3 REPLIES
Community Manager

Re: Loop through tSOAP components

Hi
When or what is the condition for the exit of the loop? Does the response may not contains IDs?
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Seven Stars

Re: Loop through tSOAP components

This looks like it can be solved in a similar way to your previous question but instead of using a simple boolean goagain to control the tLoop, use an ArrayList to hold the IDs you need to call, delete each one when calling it and loop until the ArrayList is empty.
You can have a second ArrayList that just holds all the IDs you call for use in your later tSOAPs. See this topic for an example of iterating over an ArrayList.
One Star

Re: Loop through tSOAP components

Thanks alevy, I am giving it a go using tJavaFlex and ArrayList. I've created a 'for' loop in tJavaFlex, and encompassed the entire SOAP call and the tExtractXML components in it.
Further, if I find an ID I am adding the ID to the Array List using tJavaRow, and the next time loop runs it automatically fetches the added IDs, if any (as it's dynamic in size), and processes the next SOAP call.
Shong,
The condition of the exit loop is when I have finally extracted all the IDs at some point. Some response may not contain IDs as well.