This scenario describes a Job that is called as a Webservice and stores the output data in a buffer directly on the server of the Web application. This scenario creates first a Webservice oriented Job with context variables, and next exports the Job as a Webservice.
Drop the following components from the Palette onto the design workspace: tFixedFlowInput and tBufferOutput.
Connect tFixedFlowInput to tBufferOutput using a Row Main link.
For this scenario, you will define two context variables: nb_lines and lastname. The first variable will set the number of lines the tFixedFlowInput component will generate, and the second one will set the last name to display in the output list. For more information about how to create and use context variables, see Talend Studio User Guide.
To define the two context variables:
Select the Contexts tab view of your Job, and click the [+] button at the bottom of the view to add two variables, respectively nb_lines of type Integer and lastname of type String.
In the Value field for the variables, set the last name to be displayed and the number of lines to be generated, respectively Ford and 3 in this example.
In the design workspace, select tFixedFlowInput.
Click the Component tab to define the basic settings for tFixedFlowInput.
Click the three-dot [...] button next to Edit Schema to describe the data structure you want to create from internal variables. In this scenario, the schema is made of three columns, now of type Date, firstname of type String, and lastname of type String.
Click OK to close the dialog box and accept propagating the changes when prompted by the system. The three defined columns display in the Values panel of the Basic settings view of tFixedFlowInput.
Click in the Value cell of each of the first two defined columns and press Ctrl+Space to access the global variable list.
From the global variable list, select TalendDate.getCurrentDate() and talendDatagenerator.getFirstName, for the now and firstname columns respectively.
Click in the Value cell of lastname column and press Ctrl+Space to access the global variable list.
From the global variable list, select context.lastname, the context variable you created for the last name column.
Before building your Job as a Web service, see Talend Studio User Guide for more information.
In the Repository tree view, right-click on the above created Job and select Build Job. The [Build Job] dialog box appears.
Click the Browse... button to select a directory to archive your Job in.
In the Build type panel, select the build type you want to use in the Tomcat webapp directory (WAR in this example) and click Finish. The [Build Job] dialog box disappears.
Copy the War folder and paste it in a Tomcat webapp directory.