18 Calling Web Services from Autonomous Database

Describes options for calling Web Services from Autonomous Database.

There are a number of options for calling Web Services from Autonomous Database, including the following:

See PL/SQL Packages for information on restrictions for UTL_HTTP on Autonomous Database.

Submit an HTTP Request to a Public Host with UTL_HTTP

Provides examples to submit an HTTP request on a public host.

Submit an HTTP request for a public host www.example.com:

-- Create an Access Control List for the host
BEGIN
   DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE(
         host => 'www.example.com',
         ace =>  xs$ace_type(privilege_list => xs$name_list('http'),
                             principal_name => 'ADMIN',
                             principal_type => xs_acl.ptype_db));
END;
/
-- Set Oracle Wallet location (no arguments needed)
BEGIN
   UTL_HTTP.SET_WALLET('');
END;
/
-- Submit an HTTP request
SELECT UTL_HTTP.REQUEST(url => 'https://www.example.com/') FROM dual;

Note:

If your Autonomous Database instance is on a private endpoint and you want your UTL_HTTP calls to public hosts to be subject to your private endpoint VCN's egress rules, set the ROUTE_OUTBOUND_CONNECTIONS database property to PRIVATE_ENDPOINT. See Enhanced Security for Outbound Connections with Private Endpoints for more information.

See PL/SQL Packages for information on restrictions for UTL_HTTP on Autonomous Database.

Submit an HTTP Request to a Private Host with UTL_HTTP

Provides examples to submit an HTTP request on a private host.

To submit a UTL_HTTP request to a target host on a private endpoint, the target host must be accessible from the source database's Oracle Cloud Infrastructure VCN. For example, you can connect to the target host when:

  • Both the source database and the target host are in the same Oracle Cloud Infrastructure VCN.

  • The source database and the target host are in different Oracle Cloud Infrastructure VCNs that are paired.

  • The target host is an on-premises network that is connected to the source database's Oracle Cloud Infrastructure VCN using FastConnect or VPN.

To make a UTL_HTTP call to a target on a private endpoint, make sure the following ingress and egress rules are defined:

  • Define an egress rule in the source database's subnet security list or network security group such that the traffic to the target host is allowed on port 443.

  • Define an ingress rule in the target host's subnet security list or network security group such that the traffic from the source database's IP address to port 443 is allowed.

Note:

Making UTL_HTTP calls to a private host is only supported in commercial regions and US Government regions. This feature is enabled by default in all commercial regions.

If you want to create database links from an Autonomous Database to a target in a US Government region, please file a Service Request at Oracle Cloud Support and request to enable the private endpoint in government regions database linking feature. This includes the following US Government regions:

To make a UTL_HTTP call to a target on a private endpoint, use DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE and specify the private_target parameter with value TRUE. For example:

-- Create an Access Control List for the host
BEGIN
   DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE(
         host => 'www.example.com',
         ace => xs$ace_type(privilege_list => xs$name_list('http'),
                             principal_name => 'ADMIN',
                             principal_type => xs_acl.ptype_db),
         private_target => TRUE);
END;
/
-- Set Oracle Wallet location (no arguments needed)
BEGIN
   UTL_HTTP.SET_WALLET('');
END;
/
-- Submit an HTTP request
SELECT UTL_HTTP.REQUEST(url => 'https://www.example.com/',
                        https_host => 'www.example.com') FROM dual;

Note:

If you set ROUTE_OUTBOUND_CONNECTIONS to PRIVATE_ENDPOINT, setting the private_target parameter to TRUE is not required in this API. See Enhanced Security for Outbound Connections with Private Endpoints for more information.

See PL/SQL Packages for information on restrictions for UTL_HTTP on Autonomous Database.