Web Services Templates

Template Definition Overview

Web services templates are defined using FreeMarker, a powerful templating engine. An example template for sending a JSON request to a remote server might be defined as:

{
    <#if msisdn?has_content>"msisdn": "${msisdn?json_string}"</#if>
    <#if imsi?has_content><#if msisdn?has_content>,</#if>"imsi": "${imsi?json_string}"</#if>
}
+++
{
    "endpoint": "tas-client",
    "method": "POST",
    "requestURI": "/account/create",
    "additionalHeaders": [
    ]
}
+++
{
    "imsi": "${imsi?json_string}",
    "msisdn": "${msisdn?json_string}"
}

A JSLEE web services template actually consists of three distinct FreeMarker templates, split by a +++ line:

+++

The three sections of a JSLEE web services template are:

  1. Internal parameters for EDRs. Specifically required for telecommunications services, this includes (optional) fields for msisdn and imsi. The content of this section must (after FreeMarker is run against it) be a valid JSON object.
  2. Template configuration, of fields defined below. The content of this section must (after FreeMarker is run against it) be a valid JSON object.
  3. The request body, to be sent in the HTTP request.

Template Configuration

The second section of the web services request template configuration file is meta-configuration, as JSON. This configuration may include the following options and as this section is within the FreeMarker template file, content in here is passed through the FreeMarker templating engine prior to use.

Field Type Required? Default Description
endpoint String Yes - The configured web-service client endpoint to use to send the request. Unlike most JSLEE services, this is not derived from the JSLEE message bus address.
method String Yes - The HTTP method to use. One of GET, POST, DELETE or PUT.
requestURI String Yes - The HTTP path to use in the HTTP request.
additionalHeaders Array No - A list of request headers to inject into the outbound request. Each additionalHeaders object must include a key and a value, for the header name, and header value.