Procedure
-
Double-click the tSetGlobalVar component to
display its Basic settings view in the
Component tab.
-
Click the [+] button to add a
line in the Variables table:
-
In the Key field, type in
jsonEncoded
-
In the Value fields, type in:
MetaServlet.base64Encode("{\"actionName\":\"runTask\",\"taskId\":\"" + context.task_id + "\",\"mode\"
:\"synchronous\",\"context\":{\"Default\":\"" + ((String)globalMap.get("tMsgBox_1_RESULT")) + "\"},
\"authPass\":\"" + context.tac_pwd + "\",\"authUser\":\"" + context.tac_user + "\"}")
to call the routine you have previously created.
-
Then double-click the tREST component to
display its Basic settings view.
-
Fill the URL field with the URL of the Web
service you are going to invoke. For this use case, type in:
context.tac_url + "/metaServlet?" +((String)globalMap.get("jsonEncoded"))
to call the service and encode the MetaServlet parameters in a Json
format.
-
From the HTTP Method list, select GET to send an HTTP request for generating a
task.
In this way, the MetaSerlet is invoked via the REST API of
Talend Administration Center with the
relevant parameters.
-
In the Basic settings view of the tLogRow component, select the Basic option to display the result in the Run console.
-
Save your Job and press F6 to launch
it.
Results
The console shows that the tREST component sends
an HTTP request to the server end to run the specified task, and that the task has
been executed without errors.
In the Job Conductor page of Talend Administration Center, the status of the task is
now ready to run.