RestClientApp
REST Client Application Configuration
The N2SVCD REST Client Application supports sending of REST requests over HTTP.
The REST Client Application does not initiate any user content itself. It exists only as an agent to send requests on behalf of another application.
Typical uses of the RestClientApp
are:
- As an outbound REST Gateway, the LogicApp Lua scripting logic can initiate outbound REST requests (via the RESTLuaAgent agent plugin).
- As an outbound REST Gateway, a TesterApp script can use the
rest.Request
Test operation to requestRestClientApp
to initiate outbound REST requests.
This is done by internally sending and receiving REST-...
messages over the n2svcd message bus.
See the N2SVCD Configuration Overview for more information on how the REST Application interacts with other components.
The following configuration is used to create a REST Application TCP Client instance.
<?xml version="1.0" encoding="utf-8"?>
<n2svcd>
...
<applications>
...
<application name="REST-CLIENT" module="RestClientApp">
<include><lib>../apps/rest_c/lib</lib></include>
<parameters>
<parameter name="trace_level" value="0"/>
<parameter name="remote_host" value="localhost"/>
<parameter name="remote_port" value="8118"/>
<parameter name="path" value="/servlet/ABC"/>
<parameter name="num_client_connections" value="3"/>
<parameter name="server_timeout" value="2"/>
<parameter name="ping_interval" value="3"/>
<parameter name="ping_path" value="/ping"/>
<parameter name="ping_expected_code" value="200"/>
</parameters>
<config>
<http_headers>
<http_header name="x-api-key" value="aaaaaa-bbbbbb-ccccc-dddddd"/>
</http_headers>
</config>
</application>
...
</application>
...
</n2svcd>
Configuration Details
The application
element attributes for a REST Client Application instance may include the below.
For details of the various parameter types used, refer to Common Configuration.
Parameter Name | Type | XML Type | Description |
---|---|---|---|
See: Common Application configuration | |||
See: TCP Application configuration | |||
module
|
String | Attribute |
[Required] RestClientApp
|
include.lib
|
String | Element |
[Required] ../apps/rest_c/lib
|
parameters
|
Array | Element |
[Required] As per Common Configuration Application parameters .
|
"edr_enabled"
|
- | - | This value is ignored; the REST Client Application does not support writing EDRs. |
"socket_mode"
|
String | Attribute |
The REST Client Application supports only connect (TCP Client).(Default = connect )
|
"remote_port"
|
Integer | Attribute |
As per common TCP configuration for local_port .(Default = 80 )
|
"ping_supported"
|
Boolean | Attribute |
Whether or not the Rest Client App should perform ping checks against a configured rest path. (Default = False) |
"ping_path"
|
String | Attribute |
The path component of the Ping REST URL. (Default = No Default) |
"ping_expected_code"
|
Integer | Attribute |
The expected HTTP response code to check for when executing Ping checks against the configured ping_path .If the response code is not present or does not match the expected response code the application will be set as OFFLINE .(Default = 200) |
"path"
|
String | Attribute |
The default path component of the REST URL. This may be overridden for each request. (Default = No Default) |
"security"
|
String | Attribute |
The security for the HTTP Interaction, either basic or none .This may be overridden for each request. (Default = none )
|
"username"
|
String | Attribute |
The HTTP Basic Access Authentication username to use for the HTTP Interaction. This may be overridden for each request. (Default = No Default) |
"password"
|
String | Attribute |
The HTTP Basic Access Authentication password to use for the HTTP Interaction. This may be overridden for each request. (Default = No Default) |
config
|
Object | Element | Container for extended configuration for this Application instance. |
.http_headers
|
Array | Element |
Array of REST http_header elements for additional HTTP headers to send with each REST operation.
|
REST Headers
Each http_header
Object in the config
.http_headers
Array is configured as follows.
Parameter Name | Type | XML Type | Description |
---|---|---|---|
name
|
String | Attribute | [Required] The HTTP Header key. |
value
|
String | Attribute | [Required] The HTTP Header Value. |
Each configured HTTP header will be appended to all outbound REST requests.
Application-defined static HTTP headers will be added first. Per-request HTTP headers will be added subsequently.
Message Handling
In addition to the common Application management messages, the REST Client Application uses the following messages:
- REST-C Messages (
REST-C-REQUEST
inbound).