RestClientApp

REST Client Application Configuration

The N2SVCD REST Client Application supports sending of REST requests over HTTP.

Typical uses of the RestClientApp are:

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 Client Application 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_host" String Attribute [Required] As per common TCP configuration for remote_host.
"remote_port" Integer Attribute As per common TCP configuration for remote_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" String Attribute The expected HTTP response code(s) 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)
May be a single response code, or a comma-separated list if multiple response codes are valid.
"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: