Gateway Server Programming API

 

Documentation home

 

See Also: Gateway Server, Gateway Server RESTful Services

 

 

Gateway Server JavaScript API

The Gateway Server API is divided into two sections:

 

Gateway Server

The following API methods can only be called on a Gateway Server and when the Gateway Server license feature is enabled. This can be checked in the Server Administration Application. If the Gateway Server license is not enabled a runtime error will be shown and the function will not execute.

Function Name

Description

JavaScript Example

gateway.gotoForm(remoteServer, formName)

Calls a form on the Remote Server with no additional parameters. The current user session on the Gateway Server is terminated and control is transferred to the Remote Server.

Parameters

remoteServer – name of the Remote Server as configured in the Server Administration Application. The configured Base URL is used to assemble the Remote Server form URL.

formName – The name of the form to go to on the Remote Server.

A Gateway Authentication Token is automatically added to the request sent to the Remote Server.

importPackage(com.ebasetech.xi.api);

importPackage(com.ebasetech.xi.services);

 

var remoteServer = "remoteServer1";

var formName = "customers";

gateway.gotoForm(remoteServer, formName);

gateway.gotoForm(remoteServer, formName, parameters)

Calls a form on the Remote Server with additional parameters. The current user session on the Gateway Server is terminated and control is transferred to the Remote Server.

Parameters

remoteServer – name of the Remote Server that is configured in the Server Administration Application. The configured Base URL is used to assemble the Remote Server form URL.

formName – The name of the form to go to on the Remote Server.

parametersadditional parameters to be passed to the remote form.

A Gateway Authentication Token is automatically added to the request sent to the Remote Server.

importPackage(com.ebasetech.xi.api);

importPackage(com.ebasetech.xi.services);

 

var remoteServer = "remoteServer1";

var formName = "customerDetails";

var params = {};

params.customerId = 1;

gateway.callForm(remoteServer, formName, params);

gateway.getRemoteServers()

Returns a list of configured RemoteServers that have been configured using the Server Administration Application.

 

 

importPackage(com.ebasetech.xi.api);

importPackage(com.ebasetech.xi.services);

 

var remoteServers = gateway.getRemoteServers();

remoteServers.forEach(debugServers);

 

 //debug servers

function debugServers(value, index, array) {

  log(value.getServerName());

}

gateway.isGatewayServer()

Returns true if the Gateway License feature is enabled

 

 

 

Remote Server

The following methods invoke services on a Gateway Server from a Remote Server. They can be called on any server.

Function Name

Description

JavaScript Example

gateway.getRest()

Returns the GatewayRestServices object that supports REST service calls from a Remote Server to a Gateway Server. An authorization HTTP header is added automatically to every HTTP request.

 

GatewayRestServices is an extension of RestServices and includes all the same methods get(), put(), post(), delete() etc. But each method takes the Gateway Server name (as configured in the Server Administration Application) as the first parameter, and the target URL parameter is the relative path on the target Gateway Server – see the example to the right.

 

 

importPackage(com.ebasetech.xi.api);

importPackage(com.ebasetech.xi.services);

 

var response = gateway.rest.get("MyCorp_Gateway", "/customers/getCustomer");
if (response.isSuccess())
{
    var results = JSON.parse(response.getBody());
    ..
}
 

where..

  • MyCorp_Gateway is the Gateway server name
  • customers is the name of the Gateway Web Service
  • getCustomer is the name of an endpoint inside customers