HTTP Service

With this node you can trigger the running of a JavaScript as response to a web REST call to CLOUDFLOW. One of the use cases is to allow a REST call to start a workflow.

It has the following configuration options:

  • Include Scripts: here you can define the list of script files that you want to include. Select + to add a script file.
  • Name: here you can specify the name of the configured service.

Calling an HTTP service

An HTTP service can be called in a workflow by a Call REST node. The URL needs to consist of the following parameters:

http://<server>:<port>/http_service=<name_of_the_service>&whitepaper=<name_of_the_workflow>

Example

Important parameters in this example:
  • A: HTTPservice is the name of the service.
  • B: http Service is the name of the workflow.
  • C: this means that the URL to invoke the HTTP service is http://127.0.0.1:9090/portal.cgi?http_service=HTTPservice&whitepaper=http%20Service.

Setting the output of an HTTP Service

You can set an output of the HTTP service in the script of the HTTP Service node with the parameter setOutput.

Example

In this example the output of the HTTP Service will be a variable ResultOK.

Setting the security of an HTTP Service

You can manage the authentication of an HTTP Service in the HTTP Service node and pass the credentials via the Call REST node.

Example

The user credentials are entered in the Request Data parameter field in the Call REST node:
In this example the credentials are the following:
  • Log in: admin.
  • Password: admin.
The authentication is managed in the HTTP Service node:
In this example, two scenario's can occur:
  • A user that is logged in with username admin and password admin submits a job to this workflow. In this case the credentials are valid and a CLOUFLOW session is created which triggers another workflow.
  • A user that is logged in with a username or password that is different from admin / admin submits a job to this workflow. In this case the credentials are not valid and the following log is created: Unknown user tries to connect with HttpService test3.

Converting script functions results to JSON format

In a script you can use functions. See Functions in the Script node for more information.

The function getInput() returns a string. To convert this string to JSON, you can use the function JSON.parse(getInput()).

Example

In this example, the info in the log in case of invalid user credentials is returned a string and converted to JSON.