Understanding Remote Servers

Create a Remote Server object to store REST Data Source server information.

See Also: Managing REST Data Sources

About Remote Servers

Create a Remote Server object to store REST Data Source server information.

Oracle APEX stores REST Data Source server information (for example, REST APIs) as a Remote Server object. Remote Servers can be shared among multiple REST Data Sources. Changing Remote Server properties affects all REST Sources referencing that object. For example, you can change a Remote Server’s Base URL to move all associated REST Sources from a test to a production system. Since Remote Servers are stored at the workspace-level, Remote Servers are visible in all applications in a workspace.

When you create a Remote Server you select one of the following Sever Types:

How APEX Stores REST Data Source Information

Learn how Oracle APEX stores REST Data Source information.

Oracle APEX splits the endpoint URL of a REST Data Source into two parts. The first part is the server-specific part and is stored as a separate entity called the Remote Server. You can reuse a Remote Server with multiple REST Data Sources if each one uses the same server, port, and URL Path Prefix (context root). Remote Servers are stored at the workspace-level and therefore visible in all applications.

The second part of the endpoint URL and is specific to the REST Data Source. Multiple REST Data Sources can share one Remote Server, thus sharing information such as the Base URL and Authentication. If you change Remote Server attributes, the change impacts all REST Data Sources using the Remote Server. Remote Servers make it easy to move a collection of REST Data Source. For example, you can move from a test system to a production system by changing the URL within the Remote Server object.

About Flexible Remote Servers

A Flexible Remote Server enables you to populate the server portion of the Endpoint URL dynamically using a callback procedure you specify in the Configuration Procedure attribute.

Flexible Remote Server works as follows:

Flexible Remote Server Use Cases

Common use cases for using a Flexible Remote Server include:

Note: Flexible Remote Servers are only supported for REST Data Source and Authentication Server Types or Remote Servers used in REST Enabled SQL.

Configuring a Flexible Remote Server

To configure a Flexible Remote Server, edit the Remote Server and enter a procedure name in the Configuration Procedure attribute. This procedure can be the name of a procedure stored in the database, stored in a database package procedure, or a procedure stored in the PL/SQL Code attribute.

This signature of the procedure must have two parameters of type:

The parameter p_config has two optional attributes which can be changed in the configuration procedure:

Together these two attributes determine the actual Endpoint URL the Remote Server uses.

Tip: To view Configuration Procedure examples, see item Help for the Configuration Procedure attribute.

The following example changes the base URL if the application ID is 100:

procedure my_server_config(
  p_info    in  apex_plugin.t_remote_server_info,
  p_config  out apex_plugin.t_remote_server_config )
is
begin
  if v('APP_ID') = 100 then
    p_config.base_url := 'https://app100.example.com';
  else
    p_config.base_url := 'https://example.com';
  end if;
end;

You can also can use placeholders by enclosing the “name” with the number symbol (#) and use substitutions to replace the value in those placeholders. Consider the following example:

procedure my_server_config(
  p_info in apex_plugin.t_remote_server_info,
  p_config out apex_plugin.t_remote_server_config )
is
begin
  p_config.base_url := 'https://app#app_id#.example.com/#tenant#';
  p_config.substitutions := apex_t_varchar2();
  apex_string.plist_put( p_config.substitutions, 'app_id', v('APP_ID') );
  apex_string.plist_put( p_config.substitutions, 'tenant', v('TENANT') );
end;

See Also:

Exporting and Importing Remote Server Information

Learn about exporting and importing Remote Server information.

When you export an application, referenced Remote Servers are added to the export file. When you import the application into another workspace, APEX checks whether the target workspace already contains Remote Servers with the same static ID. If a Remote Server already exists, the application uses it. Otherwise the Remote Servers from the import file are created in the target workspace.