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:

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"/>
      </parameters>
      <config>
        <headers>
          <header name="x-api-key" value="aaaaaa-bbbbbb-ccccc-dddddd"/>
      </config>
    </application>
    ...
  </application>
  ...
</n2svcd>

Configuration Details

In addition to the common Application configuration parameters and common TCP Application Configuration parameters, 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
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_interval - - This value is ignored; the REST Client Application does not support ping messages.
.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 header elements for additional HTTP headers to send with each REST operation.

REST Headers

Each header configuration defines an HTTP header to include with each outbound REST operation.

Each 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.

Message Handling

In addition to the common Application management messages, the REST Client Application uses the following messages: