REST Web Service Connections

One of the TaskCentre administrator’s responsibilities is the global configuration of connections, to make them available for task designers. This includes the configuration of web service connections.

You use the Web Service Connector tool to configure web services in TaskCentre. You can use it for both SOAP and REST web services. The tool’s global configuration is accessed in the Execute tool group.

pic1

Above: You can see the Web Service Connector tool listed in the pane on the right. To continue with the configuration, you double click the Web Service Connector name.

pic2

Above: The Web Service Configurations dialog box lists any web services already configured and allows you to edit or remove them. It also allows you to add new web service configurations.
Clicking the add button opens the New Configuration dialog box.

pic3

Above: The new configuration dialog box allows you to set a name and then select the web service description option that suits your connection architecture or standard.

For REST, which uses HTTP to pass requests to the web server and does not normally make use of WSDL or other definition files, you select the option for describing the operations based on HTTP methods.

TheREST service we are configuring provides a central bank currency rate conversion service. So we have entered “Bank of England” here as the new configuration name.

We then select the appropriate description option for REST. In this example we have selected the option ‘I do not have a definition file… I can describe the options’

pic4

Above: The HTTP Web Service Configuration dialog box, appropriate for REST services, opens. It consists of six tabbed pages.

The General tabbed page contains the name of the newly added configuration and provides a text area where you can add your own description of the service if you so choose.

pic5c

Above: The next tab is Web service root tab.

The Web service root tabbed page contains settings for specifying the web service URL and the web service type. You can obtain this either by interrogating the web service or by looking in the web service documentation. Currently available web service types include ODATA, GDATA and SDATA; there’s also an option for unknown or other types.

1- Here you enter the appropriate URL for the REST service you want to connect to. For this example, we have obtained a URL for the currency rate conversion service and entered part of it in the URL field.

When configuring REST connections, it is important to understand the structure of the URL.

Click here for some background information on the Bank of England web service.

2 – Having entered the URL, you can try interrogating the service, using the Interrogate button.

If the interrogation can successfully read back operations, the correct web service type will be automatically selected on this tabbed page and the operation details will be automatically selected and displayed where relevant in the other tabbed pages of this dialog box.

If the interrogation cannot read the operations, you will have to describe them manually, as we will do in the following example.

pic6

Above: We will now move on to the operations Tab.

The Operations tabbed page lets you create, edit and remove the HTTP messages that make up the operations of the web service, using four HTTP methods – GET, POST, PUT and DELETE.

The available HTTP messages are usually described in the API documentation for the web service.

In this example we are going to add an operation to retrieve currency rate information from the Bank of England web service.

Clicking the Add button in the Single Message Operations area opens the New HTTP Operation dialog box.

pic7b

Above: The New HTTP Operation dialog box lets you give the new operation a name and select the required HTTP operation from the four available methods. For this example, we’re using a GET operation to retrieve the currency information from the web service.

We have entered a name for the HTTP operation we are configuring – ‘GetEuroCurrencyRate’ and now need to define this operation.

Clicking OK saves this new operation,we can now start setting up its definition.

pic8

Above: The Define HTTP Operation dialog box contains four tabbed pages. The opening tabbed page displays the name of the new operation and provides space for a description if desired.

pic9

Above: We will now select the URL tab. This tab lets you build up the required URL by entering and editing parameters for the HTTP operation. You may need to refer again to the background information about the structure of the URL.

1- We have entered the root of the URL provided by the web service at the top. This is all the text up to and including “.asp?”
Notice that the same root is repeated in greyed text in the text box at the bottom.

Clicking OK accepts the settings in order to continue the configuration.

The next step is to define the operation. This builds the query string for a URL, describing the information to retrieve from the server.

2- The easiest way to start building the query is to paste the query string component of the URL, shown here, into the text box, placing it straight after the root, where you can then edit it.

pic10

Above: The full URL, including the query component, is now pasted into the text box at the bottom. We will shortly need to edit this URL, so that it includes exactly the parameter fields and values that are required.

Before this, we will enter the parameter names in the Input Parameters table. You can find the available names in the web service documentation and populate the list with the relevant parameter names.

pic11

Above: Since we require the web service to report currency rates over set periods, here we have typed in six input parameter names that we require. We got these from the web service documentation.

The next step is to identify where these names should be placed in the URL query string.

pic12

Above: Look again at the query string. A query string consists of a set of field–value pairs. The field and the value are separated by an “=“ sign. Each field–value pair is separated from others by an “&” sign.

Note that the syntax may vary from service to service. For example, some services use “EQ” instead of “=“. The documentation for the service will provide the details about the syntax.

The highlight above indicates one field–value pair: TM=Jun. In this, the field is “TM” and the value is “Jun”. For each of the parameter names we entered in the list, we can identify a corresponding field–value pair in the query string. For instance, the “ToMonth” name in the list name corresponds to “TM=Jun” in the string. What we now have to do is replace the actual value in each pair with the relevant parameter name. For example, we replace “Jun” with the parameter name “ToMonth”.

pic13

Above: The tool makes it easy to do this: you drag the parameter name from the table and drop it in position in the query string where the value is. Be sure to delete the value Itself (e.g. Jun)

pic14

Above: Here you can see that “Jun” is now replaced with “ToMonth”. The curly brackets are added automatically when you drop the name in place

pic15

Above: You will need to repeat the drag-and-drop action for each of the parameters you want to include in your operation definition.
You can see that we have done this for each of the parameters we entered in our list. The HTTP operation has now been defined.

pic17

Above: We will now look at the Output Data tab.

The Output Data tabbed page lets you specify whether output is required for this web service and to identify the type of output. This information is derived from the web service documentation.

1- For this example, output data is available and is returned as XML therefore we have selected the Output required check box.

2- The other settings on this tabbed page are now enabled.

We have left the Output type option at the default XML or JSON setting.

The Document setting is only selected when the output data is provided in one of a range of file-based formats.

3- The Document area of this tabbed page contains two tabs:

  • Schema, where you can configure schema settings
  • XML Preview, which shows XML output from a step using this operation

For the output data to be available to subsequent steps in the task, the XML or JSON schema needs to be known.

4 – You can retrieve it by sending a test message to the web service, using the Send test message button.

5 – The response to this test will be displayed in the text box.

6 – Once the data is present, the schema can be inferred from it using the Infer schema from XML or JSON button, which will be enabled.

7 – Alternatively, if a schema file is provided by the service, you can browse to it using the Browse to XSD/XML file button; then paste the XML or JSON data into the text box.

There are also options to validate the schema and to incorporate any additional schemas that are referred to by it.
We will click the Send test message button (4 – above) to retrieve the XML from this operation.

pic16

Above: The Test Web Service Configuration dialog box opens.

Here you can ensure that the relevant operation is selected, enter values for its parameters and then run the test.

1 – We have entered some values for parameters we included when building the GetEuroCurrencyRate operation.
2 – Clicking the Test Button displays the results in the results box, where they can be checked for errors.

Let’s return to the Output Data page.

pic18

Above: You can see that the XML returned by the test is now also displayed in the text box in the Schema area. From this, it is possible to infer the schema and edit it (using the Infer schema from XML or JSON button) and to validate the schema (using the Validate Schema button).

pic19

Above: The operation we have defined, GetEuroCurrencyRate, is now displayed in the list of defined operations. From here, we can again run a test, to check that the operation is correctly set up.

pic20

Above: The same Test Web Service Configuration dialog box opens as before, where you select the operation to test, enter values for its parameters and run the test.

Here we have again entered values for the input parameters and run the test. However, it is not necessary to run this test at this stage if you have successfully run it when configuring the Output Data.

Click OK to accept all your settings and close the HTTP Web Service Configuration dialog box.

pic21

Above: The newly created REST web service is now displayed in the list of available web service configurations.

REST Web Service connections: In summary

Among the global configuration done by the TaskCentre administrator is that for web service connections. REST and SOAP services are supported. Unlike SOAP, REST is not a standard, but a set of design principles, based on HTTP and XML standards.

REST uses URLs to locate resources, HTTP methods to query servers and XML as the common language between platforms or applications.
Four HTTP operations are used – POST, GET, PUT and DELETE, to create, retrieve, update and remove resources, respectively.

REST configuration is done using the Web Service Connector tool. You can add new service configurations, test, edit or delete them. You can enter parameters for selected operations, specify and test the output format, which can be XML, JSON or document format. In the case of XML and JSON, you can retrieve or infer the schema, which must be known for the output data to be usable by subsequent task steps.

Return to TaskCentre Administration

Related Articles

Background to the Bank of England URL

For your convenience, the URL for the currency rate conversion service that we’re using in this example is provided here. You can use this link to practise making the changes demonstrated in our example. http://www.bankofengland.co.uk/mfsd/iadb/fromshowcolumns.asp?Travel=NIxIRxSUx&FromSeries=50&DAT=RNG&FD=1&FM=Jan&FY=1963&TD=23&TM=Jun&TY=2011&VFD=Y&CSVF=TT&C=C8J&Filter=N&xml.x=8&xml.y=11 For configuring REST connections, you need to understand a…

Read More
BPA-14096