Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The AQ_RestServiceClient service service makes it possible to call a REST webservice. Besides the functionality found in the old AQ_WebServiceClient this service introduces the possibility of connection overriding and inputting the URL parameter as an expression. 

Parameters

The following parameters can be set for the service from StudioEncore:

NameDescriptionTypeRequiredDirectionSelect module
restServiceThe name of the REST service along with the module where it is defined.Module ElementtrueYesInputtrueYes
operationThe name of the operation of the REST service that needs to be called.StringtrueYesInputfalseNo
urlThe URL of the REST webservice.String ExpressionfalseNoInputfalseNo
connectionOverride

The name to use when overriding connection in the Runtime configuration files (more about this in the following section).

Not that if the expression returns the value unknown ( ? ) as result, an error is thrown. In this scenario no fallback is used.

String ExpressionfalseNoInputfalseNo
mappingThe name of the data mapping to use along with the module where it can be found.Data mappingfalseNoBiDirectionalfalseNo
usernameThe username to use in the service calling.StringfalseNoInputfalseNo
passwordThe password to use in the service calling.StringfalseNoInputfalseNo

Overriding parameters

...

The parameters url, username and password can be overridden in

...

the Runtime's configuration files.

...

To do so, In order to override parameters from configuration files one can use either the name of the service call of type AQ_RestServiceClient in Blueriq Encore or the value given to the connectionOverride field. For better understanding the following picture is presented:Image Removed 

Expand
titleConfiguration example

The overriding can be done in

...

the application.properties

...

 file by either using the

...

name of the service call in Blueriq Encore (SendRest20) like this:

Code Block
blueriq.connection.SendRest20.http.url=http://randomUrl:8080
blueriq.connection.SendRest20.http.username=randomUsername
blueriq.connection.SendRest20.http.password=randomPassword

... or by using the connection name (connectionName) like this:

Code Block
blueriq.connection.connectionName.http.url=http://randomUrl:8080
blueriq.connection.connectionName.http.username=randomUsername
blueriq.connection.connectionName.http.password=randomPassword
Expand
titleOverriding using the service name VERSUS overriding using

...

the connectionOverride

In order to illustrate the benefit of using the

...

new connectionOverride

...

 parameter a simple example will be presented.

Say there is webservice with 5 operations: add, subtract, multiply,

...

divide and

...

 modulo. For each operation there is a corresponding service call and for each of those service calls

...

the url, username

...

 and password

...

 are overridden in

...

the application.properties

...

 file using the name of the service

...

call. This means that even if the services call the same webservice (thus calling the same url with the same credentials) the override data must be specified for each of them. This is where the connectionOverride becomes useful by

...

allowing each of those services to use a common connection name and eliminating the need of duplication.

Info

If the value for one of those parameters is specified in more than one place (for instance if the url parameter is defined in

the Studio project

Encore but also overridden using the service name) the following prioritization is used by the Runtime:

  1. If there is a connectionOverride defined in
the Studio model
  1. Encore then that connection will be used over the others;
  2. If there is no connectionOverride defined in
the Studio model
  1. Encore, the Runtime will look into the configuration files for (and will use if it exists) a property to override parameters using the service's name;
  2. Finally, if there is no connectionOveride value defined in
the Studio model
  1. Encore and there is no property to override a parameter in the configuration files then the values defined in the
Studio
  1. model in Encore for the url, username and password will be
used.
UI Text Box
typenote
Please note that when the connectionOverride expression returns the value unknown ( ? ) as result, an error is thrown. In this scenario no fallback is
  1. used.


Warning
titleFinal considerations

One must be consistent in the way it assigns value to the service parameters. Giving value to one parameter in a place and to another parameter in another place might prove faulty. For instance if one overrides the url by using a connection override but keeps the username and password values in the Studio model Encore, the latter will not be used by the Runtime since it expects them to also be overridden in the configuration files.

Error handling

...

When the runtime sumbles upon an arror during execution of the AQ_RestServiceClient, there are serveral options to handle this:

  • The exception exit can be used to handle exceptions such as a failing data mapping, or a response body that doesn't match the domain schema

...

  • .
  • Use the

...

  • exit events to handle timeouts, client errors (http status code 4xx), and server errors (http status code 5xx).
    • If there is a need to distinguish on a more specific http status code than the aforemantioned ranges, you can use the header in the REST service to map the status code with the name "Status" to the profile.

Exit events

NameDescriptionType
TimeoutWhen the REST request returns a timeout exception.

Continue

ClientError (since 16.7)When the REST request returns a 4xx exception.

Continue

ServerError (since 16.7)When the REST request returns a 5xx exception.

Continue

...

default exit event

All unmapped events will be redirected to the default exit node of the service call, even errors. Therefore it is recommended to always map all possible expected exit events.

Continue

Authentication options

There are several authentication options, which are configurable per connection with properties:

...

When no username and password are set for the service call (none is Studio and also non in Encore and also none in the Connections Properties), then no authentication will be attempted. You should use this when the Rest Endpoint that you are calling is not secured.

...

When a username and password are supplied, either in Studio or Encore or in the Connections Properties, these credentials will be supplied to the Rest Endpoint.

...