
Anonymous
Not applicable
2013-04-10
08:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
[resolved] Extract a XML tag from a SOAP response (in loop)
Hi,
I want to use one of the XML tag values (coming from a SOAP response) in a tJava component, in such a way that I can limit the number of SOAP Requests sent.
I am setting the tLoop "To" component to context.lastValue. I want this value to be dynamically updated (after every SOAP response is generated) with the help of tJava (or some other component), so that the SOAP requests don't overshoot (loops only for a certain number of times).
My XML response is somewhat like this:
<Soap>
<soap:Envelope xmlns:soap=" http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd=" http://www.w3.org/2001/XMLSchema">
<soap:Body>
<SearchResponse xmlns="http://localhost/service/">
<SearchResult>
<?xml version="1.0" encoding="utf-16"?>
<Records count="1000">
<Metadata></Metadata>
<Record>1</Record>
<Record>2</Record>
</Records>
</SearchResult>
</SearchResponse>
</soap:Body>
</soap:Envelope>
</Soap>
What I want to extract is the "count" value (which is 1000 in this case). I want to then use this count in my tJava component (to set the lastValue context).
I don't prefer using additional XML files, but can anyone help me out on this?
My flow is as shown in the diagram.
I want to use one of the XML tag values (coming from a SOAP response) in a tJava component, in such a way that I can limit the number of SOAP Requests sent.
I am setting the tLoop "To" component to context.lastValue. I want this value to be dynamically updated (after every SOAP response is generated) with the help of tJava (or some other component), so that the SOAP requests don't overshoot (loops only for a certain number of times).
My XML response is somewhat like this:
<Soap>
<soap:Envelope xmlns:soap=" http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd=" http://www.w3.org/2001/XMLSchema">
<soap:Body>
<SearchResponse xmlns="http://localhost/service/">
<SearchResult>
<?xml version="1.0" encoding="utf-16"?>
<Records count="1000">
<Metadata></Metadata>
<Record>1</Record>
<Record>2</Record>
</Records>
</SearchResult>
</SearchResponse>
</soap:Body>
</soap:Envelope>
</Soap>
What I want to extract is the "count" value (which is 1000 in this case). I want to then use this count in my tJava component (to set the lastValue context).
I don't prefer using additional XML files, but can anyone help me out on this?
My flow is as shown in the diagram.
661 Views
1 Solution
Accepted Solutions

Anonymous
Not applicable
2013-04-26
03:58 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Okay, I got this one figured out, I used a tReplicate component to replicate the outputs from SOAP to XML File and to a ExtracXMLField. Further, I used a main from ExtractXMLField to push output into Buffer Output component, and an Iterate to tJava where I used the Buffer Output to set the Page Number.
So I used: tLoop -> Iterate -> iSOAP -> main -> tUnite -> tReplicate -> main -> 1) Buffer <- main <- ExtractXML -> Iterate -> tJava and main2 -> 2) XMLFile
Thanks for the help!
So I used: tLoop -> Iterate -> iSOAP -> main -> tUnite -> tReplicate -> main -> 1) Buffer <- main <- ExtractXML -> Iterate -> tJava and main2 -> 2) XMLFile
Thanks for the help!
661 Views
6 Replies

Anonymous
Not applicable
2013-04-17
01:06 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
You need to use a tExtractXMLField to extract the "count" value from the response of tSOAP component. For more details about this component, see
https://help.talend.com/search/all?query=tExtractXMLField&content-lang=en
But I don't understand why you need to set the TO filed with the count value, does tSOAP (in loop) returns the same response each time?
Shong
You need to use a tExtractXMLField to extract the "count" value from the response of tSOAP component. For more details about this component, see
https://help.talend.com/search/all?query=tExtractXMLField&content-lang=en
But I don't understand why you need to set the TO filed with the count value, does tSOAP (in loop) returns the same response each time?
Shong
661 Views

Anonymous
Not applicable
2013-04-23
10:43 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, the SOAP returns count = "1000" every time the SOAP is called. So I need to query the same SOAP, with only one parameter change, that depends on the count. Say I have 10 records being returned for the first SOAP request, I need to divide count/that-number (in this case: 1000/10 = 100).
So I need to call this SOAP request 100 times and not 1000 times. In short, I want to extract the count field's value (which is constant for all SOAP response), perform the calculation and set the "To" in the Loop field with this new calculated value = 100.
How can I achieve this?
So I need to call this SOAP request 100 times and not 1000 times. In short, I want to extract the count field's value (which is constant for all SOAP response), perform the calculation and set the "To" in the Loop field with this new calculated value = 100.
How can I achieve this?
661 Views

Anonymous
Not applicable
2013-04-23
02:06 PM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
You can set the To field with context variable, let's say it context.to. After calling the SOAP, use a textractXMLField to extract the count value and populate the new value to context.to on tJavaRow, the job looks like:
tloop--iterate---tSOAP--main--tEXtractXMLField--main--tJavaRow
on tJavaRow:
context.to=input_row.count/10
Shong
You can set the To field with context variable, let's say it context.to. After calling the SOAP, use a textractXMLField to extract the count value and populate the new value to context.to on tJavaRow, the job looks like:
tloop--iterate---tSOAP--main--tEXtractXMLField--main--tJavaRow
on tJavaRow:
context.to=input_row.count/10
Shong
661 Views

Anonymous
Not applicable
2013-04-24
06:41 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Okay, so in my job, the SOAP is connected to tUnite, which eventually feeds the data (from all the iterations) into a single file. That is connected through main.
But you are suggesting to use main to tExtractXMLField and then Java component. All the more, I just need to pick up the "count" value from this response. I could probably, dump the data into a temp file and then parse it, but that would just increase the overhead of SOAP in loop.
Please see the screenshot attached. Also, the XPath query should be SearchResponse/SearchResult/Records right (considering I don't have soap, soap:envelope and soap:body tags) ?
But you are suggesting to use main to tExtractXMLField and then Java component. All the more, I just need to pick up the "count" value from this response. I could probably, dump the data into a temp file and then parse it, but that would just increase the overhead of SOAP in loop.
Please see the screenshot attached. Also, the XPath query should be SearchResponse/SearchResult/Records right (considering I don't have soap, soap:envelope and soap:body tags) ?
661 Views

Anonymous
Not applicable
2013-04-26
03:58 AM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Okay, I got this one figured out, I used a tReplicate component to replicate the outputs from SOAP to XML File and to a ExtracXMLField. Further, I used a main from ExtractXMLField to push output into Buffer Output component, and an Iterate to tJava where I used the Buffer Output to set the Page Number.
So I used: tLoop -> Iterate -> iSOAP -> main -> tUnite -> tReplicate -> main -> 1) Buffer <- main <- ExtractXML -> Iterate -> tJava and main2 -> 2) XMLFile
Thanks for the help!
So I used: tLoop -> Iterate -> iSOAP -> main -> tUnite -> tReplicate -> main -> 1) Buffer <- main <- ExtractXML -> Iterate -> tJava and main2 -> 2) XMLFile
Thanks for the help!
662 Views

Specialist III
2016-08-04
10:17 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
661 Views
