Creating a SayHello provider - 6.1

Talend ESB Getting Started Guide

EnrichVersion
6.1
EnrichProdName
Talend ESB
task
Design and Development
EnrichPlatform
Talend Studio

This section provides you a step by step instruction to build the SayHello provider.

Creating a service

In this section, you will create a WSDL which defines the external contract to the Web service that clients can use.

  1. To create the service, right-click Services in the left hand menu and select Create Service.

  2. Enter the name SayHelloService, purpose Demo and a description of the service, and click Next.

  3. In the next step called [Assign WSDL], select Create new WSDL and click Finish to return to the main screen.

  4. Now the main window has a [SayHelloService_0.1.wsdl] tab displayed. This WSDL contains a new port (SayHelloServicePort) for the service, and default request and response operations (SayHelloServiceOperationRequest and SayHelloServiceOperationResponse respectively). Hover over the grey arrows to the right of the operations to display their parameters:

    It is possible to make changes to the operations - add new operations and edit existing ones. However, the default operations are enough for this demo example.

Configuring and exposing a service

  1. Save the service details and WSDL Request / Response data types to the Metadata so that they can be accessible to other components. So, in Services, right-click SayHelloService 0.1 and select Import WSDL Schemas.

    This option imports the WSDL metadata from the service into the Repository, under the Metadata > File xml. This allows you to share the operations details across services and other components.

  2. Implement the operation - expand the elements displayed in SayHelloService 0.1, right-click SayHelloServiceOperation 0.1 and select Assign Job. In the wizard, select Create a new Job and Assign it to this Service Operation, and click Next.

    Keep the default name and prefix SayHelloServicePortType_SayHelloServiceOperation, and click Finish. This creates a new job, which allows to implement the operations using components in the main grid.

  3. The default template of the SayHelloServicePortType_SayHelloServiceOperation Job is made of the tESBProviderRequest and the tESBProviderResponse components. Separate the two ESB components on the grid by clicking on the tESBProviderResponse_1 icon, and dragging it further to the right.

  4. Now add some business logic. tXMLMap is a component that transforms and routes data from single or multiple sources to single or multiple destinations. Perform a search for the tXMLMap component in the Palette on the right hand side. There may be two instances found under different sections, but they are both the same, so select either. Drag and drop it between the two ESB components.

  5. Right-click the center of tESBProviderRequest_1 and select Row, then Main and drop the end of the line on tXMLMap_1.

  6. Next, right-click tXMLMap_1 and select Row, then Main and drop the end of the line on tESBProviderResponse_1. Give it the name Response, and click OK. Click the default Yes when asked if you wish to import the schemas.

Configuring the service operation

  1. Now customize the service operation to match the scenario. Double-click tXMLMap_1 to open its editor. tXMLMap is used to route the information from the request to the response, and make use of the existing schema information from the WDSL.

  2. Under main :row1 on the left hand side, right-click payload and select Import from Repository. In the [Metadata] wizard that appears, navigate from File XML to SayHelloServiceOperationRequest0.1, select it and click OK.

  3. In the same way, on the right hand side, import the default response type, right-click payload then Import from repository > File XML and select SayHelloServiceOperationResponse 0.1.

    Click OK.

    So, the request and response operations are implemented from the existing schemas.

  4. Next, simply link the request schema to the response one: left-click in on the left hand side and drag it to the out expression in the response on the right hand side.

  5. Next, modify the default expression that is sent. On the right hand side, under Expression, click the HelloServiceOperationRequest value, and click the [...] button beside it. Edit the expression (which will evaluate to a name) by clicking in the field, and add "Hello " + before it, and +"!" after it.

    Click OK. You will see the updated expression now on the right hand side. Click OK to return to the main Job design window.

  6. Finally, in order to see more as the Job executes, add a logging component. This is done simply by searching for tLog in the palette, and dragging tLogRow from the Palette on the right hand side and dropping it on the Response link between the tXMLMap_1 and tESBProviderResponse_1.

    Now, the implementation of the SayHelloServiceOperation is complete.

Running the service in the Talend Studio

Do a quick check now to make sure this part is working, by clicking the tab Run (Job SayHello...) in middle section in the bottom half of the window, and then clicking the Run button.