Description
The BigAnimal Oracle compatibility version offers the UTL_HTTP module as part of the Oracle compatibility feature. UTL_HTTP lets you connect through the HTTP protocol to a remote server using HTTP methods like GET, POST, and PUT.
- The default port allowed for external connections is the https one 443.
- If the connection is to a server deployed in your private cloud network, ports 80 and 443 are allowed.
- For any other port, it is advisable to get in touch with BigAnimal support.
Examples
Listing headers from external website (www.enterprisedb.com) with https:
DECLARE
v_req UTL_HTTP.REQ;
v_resp UTL_HTTP.RESP;
v_name VARCHAR2(2000);
v_value VARCHAR2(2000);
v_header_cnt INTEGER;
BEGIN
-- Initiate request and get response
v_req := UTL_HTTP.BEGIN_REQUEST('https://www.enterprisedb.com');
v_resp := UTL_HTTP.GET_RESPONSE(v_req);
-- Get header count
v_header_cnt := UTL_HTTP.GET_HEADER_COUNT(v_resp);
DBMS_OUTPUT.PUT_LINE('Header Count: ' || v_header_cnt);
-- Get all headers
FOR i IN 1 .. v_header_cnt LOOP
UTL_HTTP.GET_HEADER(v_resp, i, v_name, v_value);
DBMS_OUTPUT.PUT_LINE(v_name || ': ' || v_value);
END LOOP;
-- Terminate request
UTL_HTTP.END_RESPONSE(v_resp);
END;
The output is:
Header Count: 25
Accept-Ranges: bytes
Age: 1
Cache-Control: must-revalidate, no-cache, private
Content-Language: en
Content-Security-Policy-Report-Only: report-uri /report-csp-violation
Content-Type: text/html; charset=UTF-8
Date: Mon, 08 May 2023 14:38:41 GMT
Expires: Sun, 19 Nov 1978 05:00:00 GMT
From-Origin: same
Server: Netlify
Strict-Transport-Security: max-age=31536000
Via: varnish
X-Ah-Environment: prod
X-Cache: MISS
X-Content-Security-Policy-Report-Only: report-uri /report-csp-violation
X-Content-Type-Options: nosniff
X-Drupal-Cache: HIT
X-Drupal-Dynamic-Cache: HIT
X-Frame-Options: SAMEORIGIN
X-Generator: Drupal 9 (https://www.drupal.org)
X-Nf-Request-Id: 01GZXWSR4B3EEVHWQVVG4F8KDQ
X-Request-Id: v-06aff0be-edae-11ed-973a-434a4f71b679
X-Ua-Compatible: IE=edge
X-Webkit-Csp-Report-Only: report-uri /report-csp-violation
Transfer-Encoding: chunked
EDB-SPL Procedure successfully completed
Query returned successfully in 716 msec.
Calling POST method
DECLARE
v_req UTL_HTTP.REQ;
v_resp UTL_HTTP.RESP;
BEGIN
v_req := UTL_HTTP.BEGIN_REQUEST('https://www.enterprisedb.com',
'POST');
UTL_HTTP.SET_HEADER(v_req, 'Content-Length', '28');
UTL_HTTP.WRITE_TEXT(v_req, 'Fake value, just an example!');
v_resp := UTL_HTTP.GET_RESPONSE(v_req);
DBMS_OUTPUT.PUT_LINE('Status Code: ' || v_resp.status_code);
DBMS_OUTPUT.PUT_LINE('Reason Phrase: ' || v_resp.reason_phrase);
UTL_HTTP.END_RESPONSE(v_resp);
END;
The output is:
Status Code: 200
Reason Phrase: OK
EDB-SPL Procedure successfully completed
Query returned successfully in 1 secs 241 msec.