Calling a RESTful web service
This recipe shows how a RESTful web service can be called from Talend. The REST service we will be using is a Google maps service, so you will need to be connected to the Internet to perform this recipe.
Getting ready
Open the job jo_cook_ch09_0070_consumeRestService
.
How to do it...
Drag a
tRESTClient
component onto the canvas.Set the URL to http://maps.googleapis.com the Relative Path to
"maps/api/geocode/xml"
.Add two Query Parameters
"address"
with a value of"Trafalgar Square"
and"sensor"
with a value of"false"
.Your
tRestClient
should look like the one below:Link a
tLogRow
component to the response and error flows out of thetRestClient
component.Run the job.
How it works...
The tRestClient
is a component that enables us to define all of the features of a REST request. In this case, we define the URL of the Google APIs, and then the Geocoder API within the maps functions.
Finally, we define the address for which we wish to provide the information.