问题描述
我的拓蓝招聘结构如下:
My Talend Job has the following structure:
-
特热什季组件执行POST HTTP请求,并接收XML文件。
tREST component that executes a POST HTTP Request, and receives a XML file.
tExtractXMLField 组件从XML文件中读取一个标签,如:
tExtractXMLField component that reads a tag from that XML file, like:
现在,我想所有的值从Tagx传送保存,然后访问它们。对于每个Tagx传送的价值,我将执行在体内该值的HTTP POST。我该怎么做?
Now, I want to save all the values from the tagX, and then access them. For each value of the tagX, I will perform a HTTP POST with that value in the body. How can I do that?
感谢
推荐答案
您需要调用的组件 tHtt prequest
。但该组件不允许被连接到行流动。但是有实现的一种方式。
You need a component called tHttpRequest
. But this component doesn't allow to be connected to row flows. But there's a way to accomplish.
假设你提取你的Tagx广告领域,并把价值上称为Tagx传送'你送到一个传出连接字符串字段。然后,您需要的组件tFlowToIterate的行连接到一个迭代的连接转换。看迭代连接作为一种信号,即不包含数据的;它在触发每个传入迭代。下面这个子作业调用tJava code(这反过来版画世界你好的控制台)的每一行传入从tExtractXMLField:
Let's say you extracted your tagX field and put the value on a String field called 'tagX' you fed to an outgoing connection. You then need the component 'tFlowToIterate' to convert a row connection to a iterate connection. Look the iterate connection as a kind of signal that doesn't contain data; it's triggered at each incoming iteration. This subjob below calls the tJava code (which in turn prints 'hello world' on console) for every row incoming from tExtractXMLField:
现在的魔力。 tFlowToIterate里面的参数可以定义一个或多个从传入的连接领域喂全局变量。上面的例子设定的全局变量富
与连接领域客户
的值 ROW2
:
使用(字符串)globalMap.get(富)这个变量是现在在你的工作拓蓝访问的处处
。小心转换为适当的类型,因为办事处一览是唯一对象的集合。
This variable is now accessible everywhere in your Talend job using (String)globalMap.get("foo")
. Be careful to cast to the proper type, as globalMap is a Object-only collection.
要参数化的HTTP POST调用,你只需要与你刚才设置的变量tHtt prequest组件:
To parametrize your HTTP post call, you just need a tHttpRequest component with the variable you just set:
现在它是由你来处理tHtt prequest输出(与整个响应一个大的字符串字段)。请记住,在输入行,变换为迭代信号时,失去了他们的数据(保存到办事处一览字段没有技术上自己到流动了),但总数不变。所以,如果你有,比方说,4传入行,你会三角函数的迭代信号4次,导致所涉及的办事处一览变量被刷新,并tHtt prequest组件,使4(参数化)HTTP自动请求。
Now it's up to you to handle tHttpRequest output (a single big String field with the entire response). Remember that rows in in input, when converted to Iterate signal, lost their data (the fields you saved into the globalMap don't technically own to the flow anymore) but the total number is unchanged. So, if you have, let's say, 4 incoming rows, you will trig the Iterate signal 4 times, causing the involved globalMap variables to be refreshed and tHttpRequest component to make 4 (parametrized) http requests automatically.
这篇关于访问"字符串数组"从tExtractXMLField(带+1价值XML标记)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!