Echo to upper case

In this example, we will demonstrate how to create a data service that returns the message converted to upper case. The web service will be available on http://www.example.com/clover/data-service/message

Solution

Creating a data service

Create a new Data Service REST Job. Right click the data-service directory in project. NewOther. CloverETLData Service REST Job Enter the file name and click Finish.

Remove other components except Input and Output.

Insert the GetJobInput component: Press Shift+space and choose the component.

Connect GetJobInput and Output with an edge.

Assign metadata to the edge. The metadata should contain one string field.

In GetJobInput, update the transformation to contain the following mapping:

function integer transform() {
 	string text = getRequestParameter("text");
 	string upperText = upperCase(text);
 	setResponseBody(upperText);

 	return ALL;
}

Publishing the web service

To publish the web service, switch to Endpoint Configuration. Set Endpoint URL.

Check request methods GET and POST.

Click Publish.

Checking that it works

To check that the service works, query the data service, e.g. with wget (or curl). You can also use HTTPConnector.

wget --user clover --password clover "http://example.org/clover/data-service/message?text=Hello" -O -

The data service will return HELLO.