How to create a service with Talend Open Studio for ESB Learn how to create a service provider from an existing WSDL file

In this tutorial, you will see how to build your first Web Service with either Talend Open Studio for ESB or Talend Enterprise ESB Studio by using the new Service wizard and generate automatically its corresponding provider Job. We will also see how to use Talend ESB Web Service components and the new tXMLMap.

To do so, we will use a WSDL file from which we will create an airport Web Service; we will automatically generate the provider process corresponding to this service. Then, we will create a consumer process that will send a request to the service and retrieve the response.

Prerequisites:
To follow this tutorial, Talend Open Studio for ESB or Talend Enterprise ESB Studio should already be installed and running.
You need to download and unzip the exampleFile.zip file available at the bottom of this page, in the Download it! section of this tutorial.

Once unzipped, you will get an airport_soap.wsdl file: the WSDL file used for this tutorial to create the Service.

Download it!

You want to practice?

Download exampleFile.zip to get the files used for this tutorial.

You can also download tutorialProject.zip containing all the jobs needed to carry out this tutorial.

You can also:
Send it!

Share it!
Next Step: Learn [How to deploy a service in Talend Runtime] or [How to make a join with tXMLMap]

 


Create a Web Service from a WSDL


In the Repository to the left of the Studio's main screen:

Right-click Services.

In the menu, click Create Service to open the New Service wizard.

Next
In the New Service wizard:

In the Name field, name the service Airport.

Click Next to continue the creation.

Next
In the second step of the New Service wizard:

Select the Import existing WSDL option as we are creating a service from an existing WSDL file.

Click the Browse... and browse to the WSDL file you downloaded from the Download it! section of this tutorial, the WSDL file field is filled in with the path to this WSDL file.

Select the Import WSDL Schema on finish check box to automatically generate the request and response schemas of this service and store them in the File XML metadata node of the Repository.

Click Finish to close the wizard, and create and open the service on the WSDL editor.

Next
In the Repository:

The new Airport service item is created under the Services node.

The request and response schemas corresponding to this service have been created and are stored under the File XML metadata node.

Next
To be able to request this service we have to create its provider. To do so, let's generate automatically the provider Job Design:

Expand the Airport service item.

Right-click its getAirportInformationByISOCountryCode operation and select Create New Job in the menu.

Next
In the New Job wizard:

Leave the Name field as is, as it retrieves the name of the port and operation of the Airport Service.

Click Finish to close the wizard and create and open the provider Job Design corresponding to the Airport Service.

Next
In the Repository:

The new airportSoap_getAirportInformationByISO
CountryCode
Job is created under the Job Designs node.

And in the Designer, it opens with the two preconfigured tESBProviderRequest and tESBProviderResponse components.

Next
On the Designer:

To link the components together, right-click tESBProviderRequest, hold and drag it to tESBProviderResponse.

The Job is ready to be used, so press F6 to run it.
The Job is automatically saved before being executed.

The Run view displays at the bottom of the Studio and the console follows the execution. We can see that the Web Service from the WSDL has been published to the following endpoint: http://localhost:8200/esb/AirportService.

The Job is started and waits for requests.

Next
To check the WSDL, simply copy and paste the endpoint address on which it has been published: http://localhost:8200/esb/AirportService and type in ?WSDL at the end of the URL.

Next
Implement a new operation for the service with tXMLMap


To further implement the service, we will create an operation. To do so:

In the Palette to the right:

Search for tXMLMap in the Find component... field and press Enter.
tXMLMap belongs to two different families.

Click one or the other tXMLMap component and drop it between the two ESB components onto the row1 link.

Next
After you dropped the tXMLMap component, a tXMLMap Output pop-up prompts asking you to name the output link, type in response and click OK.

Click Yes when asked if you want to get the schema from the target component.

Next
tXMLMap is integrated into the main flow of the Job between the tESBProviderRequest and tESBProviderResponse components.

Double-click it to open its editor and configure the operation to implement.

Next
In the tXMLMap editor:

Right-click the default payload node of the row1 input table.

Click Import From Repository in the menu to import the XML schema directly from the Repository as you automatically generated it from your WSDL.

Next


If you did not select the Import WSDL Schemas on finish check box when creating your service, no schemas will be available from Repository.
In that case, you can generate the schemas at this stage simply by right-clicking your Service and selecting Import WSDL Schemas in the menu.

In the Metadata wizard:

Browse to the request schema: getAirportInformationByISOCountryCode.

Click OK.

Next
The request schema is imported to the input row1 table with the appropriate name space and loop element defined.

Repeat the operation for the output table:

Right-click the default payload node of the response output table.

Click Import From Repository in the menu to import the XML schema directly from the Repository as you automatically generated it from your WSDL.

Next
In the Metadata wizard:

Browse to the response schema this time: getAirportInformationByISOCountryCodeResponse.

Click OK.

Next
The same way, the response schema is imported to the output response table with the appropriate name space and loop element defined.

Connect the request and response schemas together:
Select the tns:CountryAbbrviation node of the row1 table and drop it to the tns:getAirportInformationByISOCountryCodeResult node of the response table.

Click Apply to apply the changes and OK to validate.

Next
In the Designer:

Press F6 to run the Job.
The Job is automatically saved before being executed.

The Run view displays at the bottom of the Studio and the console follows the execution. We can see that the Web Service from the WSDL has been published to the following endpoint: http://localhost:8200/esb/AirportService.

The Job is started and waits for requests.

Next
Create a consumer data service Job Design


In the Repository view:

Right-click Job Designs.

In the menu, click Create Job to open the New Job wizard.

Next
In the New Job wizard:

In the Name field, fill in the name of the Job: AirportConsumer.

Click Finish to close the wizard and create the Job.

The Designer opens an empty Job.

Next


In the Name field, accents, special characters and spaces are invalid. Also do not use numbers to start the field.

In the Palette to the right:

To add an input component that will send a country code request to the tESBConsumer component, in the Find component... field, search for tFixedFlowInput and press Enter.

Under the Misc family, click the tFixedFlowInput component and drop it onto the Designer, to the left of the canvas.

Next
In the Palette:

The same way, search for tXMLMap.

Under the Processing family, click the tXMLMap component and drop it onto the Designer next to tFixedFlowInput.

tXMLMap will transform the string data (the country code) inputted to XML data, as ESB components expect XML data as input.

Next
In the Palette:

To add the ESB component that will request the corresponding Web Service, search for tESBConsumer.

Under ESB > Web Services, click the tESBConsumer component and drop it onto the Designer next to tXMLMap.

Next
To display the result of the request in the console, add two tLogRow components: one for the responses and one for the rejects.

In the Palette:


Search for tLogRow.

Under the Logs & Errors family, click tLogRow and drop it onto the Designer. Repeat this step to add the second tLogRow.

Next
On the Designer:

To link the components together, right-click tFixedFlowInput, hold and drag to tXMLMap.

Follow the same procedure to link tXMLMap to tESBConsumer and name the output link request when asked by the tXMLMap Output pop-up. Click Yes when asked if you want to get the schema from the target component.

To link the consumer to the two tLogRow components:
- Right-click tESBConsumer, select Row > Response in the menu and click the top tLogRow.
- Right-click tESBConsumer, select Row > Fault in the menu and click the bottom tLogRow.

Next
Now we will set the properties of the components.

On the Designer:

Double-click the tFixedFlowInput component to display its corresponding Component view and set its properties.

In the Component view:

Click [...] next to the Edit schema field to define the schema of the component.

Next
In the Schema of tFixedFlowInput wizard:

Click the [+] button once to add a new column to the schema.

Rename this column code and leave its Type as String.

Click OK to validate.

Next
Back to the Component view of tFixedFlowInput:

Note: the schema you just defined is automatically propagated to the different Mode area options.

Keep the Use Single Table option selected in the Mode area.

In the Value field of the code Column, type in FOO between double quotes.

Next
On the Designer:

Click tXMLMap to select it and click the Component view at the bottom of the Studio to display its properties.

Click [...] next to the Map Editor field to open the component's editor.

Note:
you can also simply double-click tXMLMap on the Designer and its editor will open.

Next
In the tXMLMap editor:

Right-click the default payload node of the request output table.

Click Import From Repository in the menu to import the XML schema directly from the Repository as you automatically generated it from your WSDL.

Next
In the Metadata wizard:

Browse to the request schema: getAirportInformationByISOCountryCode.

Click OK.

Next
Now drop the code column from the row1 input table to the tns:CountryAbbrviation node of the request output table.

Click Apply to apply the changes and OK to validate.

Next
On the Designer:

Click tESBConsumer to select it and click the Component view at the bottom of the Studio to display its properties.

Click [...] next to Service configuration to open the component's editor.

Note: you can also simply double-click tESBConsumer on the Designer and its editor will open.

Next
In tESBConsumer editor:

In the WSDL field, paste the URI of the WSDL you put as a service: http://localhost:8200/esb/AirportService?WSDL and click the Refresh button to retrieve its information.

In the Port Name field, select airportSoap.

In the Operation field, select getAirportInformationByISOCountryCode.

Click OK to validate the configuration.

Note: there is no need to select the Populate schema to repository on finish, as you already exported the schema to the File XML metadata when creating the Service.

Next
In the Designer:

Press F6 to run the Job.
The Job is automatically saved before being executed.

The Run view displays at the bottom of the Studio and the console follows the execution. We can see that FOO has been transformed into XML and sent to the consumer.

Next
And if you have a look at the airportSoap_getAirportInformationByISO
CountryCode
Job, you can see that the request sent by the consumer requested the provider Job of your Airport Service, as one row has been processed by the provider.

Note: the provider is still listening for request, so if you want to stop it, you will have to click the Kill button of the Run view.


 

    Download it!     Send it!     Share it!

You want to practice?

Download exampleFile.zip to get the files used for this tutorial.

You can also download tutorialProject.zip containing all the jobs needed to carry out this tutorial.

Friends / colleagues may be interested in this tutorial? Send it to them!

You liked this tutorial ? Support it!

[ top ]