One Star

tWebservice - pass through Parameters (Input to Output)

hy!
I try to use the tWebservice component to update/insert a webshop.
I pass Category_ID, Name etc. to the WS and receive the new ID (from the Webshop) as result.
Now I have to update the local table with the ID. But I can not find a way to passthrough Category_ID from "Input Mapping" to "Output Mapping" to know which Category to update!

Can somebody advice me how to do that?
Thank you in advanced!
Robert
4 REPLIES
Community Manager

Re: tWebservice - pass through Parameters (Input to Output)

Hi Robert
You need to iterate each row and then you are able to access the Category_ID after getting the new ID, for example:
tMysqlInput--row1--tFlowToIterate--iterate--tFixedFowInput--row2--tWebService--row3--tMap---out--tMysqlOutput
on tFixedFlowInput: define the same schema as tMysqlInput's schema, set the value of each column as (for example, for Category_ID column):
(Integer)globalMap.get("row1.Category_ID")
on the output table of tMap, add new column called 'Category_ID', the column you will use as a key for updating, set its values as:
(Integer)globalMap.get("row1.Category_ID")
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: tWebservice - pass through Parameters (Input to Output)

Thank you very much for your answer!
I'll try it as proposed!
thx & regards,
Robert
One Star

Re: tWebservice - pass through Parameters (Input to Output)

Thank you Shong!
It worked according to your description!
Now I have the problem, that new ID should be included in the first view.
Background:
I tranfer Categories (Treeview) to a webshop via tWebService. From the tWebService I get the new ID of the Category (in the Webshop). This new ID must now also be used for the "belongsToID" (mother-ID).
So the result of the Flow-Schema (tMysqlOutput) should influence the start of the schema(tMysqlInput):
tMysqlInput--row1--tFlowToIterate--iterate--tFixedFowInput--row2--tWebService--row3--tMap---out--tMysqlOutput
example data:
Category_ID, CatName, belongsToID, WebShopCat_ID
Datarow:
1, "TestCat", null, <X = gets the ID From Webservice>
2, "SubTestCat", 1(ToChange!), <Y = gets the ID From Webservice>
Submitting the second row I would like to take X instead of 1.
In my current solution this is not possible because talend load all datarows bevor starting to submit to webservice, at this moment the new IDs are not available.
I hope I explained it clear enough ?! :-)
Thank you
Robert
One Star

Re: tWebservice - pass through Parameters (Input to Output)

Another way to do this quite easily is to use a tJavaRow component and referencing the columns from upstream components. 
See attached. I read 5 columns from a file, and pass one of the columns (First Name) to the tWebservice component for encryption. The component returns only the encrypted value of the First Name, but does not have a way to pass through the other 4 fields. Using a tJavaRow, I call the 4 other fields downstream.