49.1.4 Retrieving Cookies and HTTP Headers
When you invoke a Web service using any of the supported methods in Oracle APEX, the g_response_cookies
and g_headers
globals are populated if the Web service response included any cookies or HTTP headers. You can interrogate these globals and store the information in collections.
When you invoke a Web service using any of the supported methods in APEX, the g_status_code
global is populated with the numeric HTTP status code of the response (for example, 200 or 404). The g_response_cookies
and g_headers
globals are populated if the Web service response included any cookies or HTTP headers.
The following are examples of interrogating the APEX_WEB_SERVICE
globals to store cookie and HTTP header responses in collections.
DECLARE
i number;
secure varchar2(1);
BEGIN
apex_collection.create_or_truncate_collection('P31_RESP_COOKIES');
FOR i in 1.. apex_web_service.g_response_cookies.count LOOP
IF (apex_web_service.g_response_cookies(i).secure) THEN
secure := 'Y';
ELSE
secure := 'N';
END IF;
apex_collection.add_member(p_collection_name => 'P31_RESP_COOKIES',
p_c001 => apex_web_service.g_response_cookies(i).name,
p_c002 => apex_web_service.g_response_cookies(i).value,
p_c003 => apex_web_service.g_response_cookies(i).domain,
p_c004 => apex_web_service.g_response_cookies(i).expire,
p_c005 => apex_web_service.g_response_cookies(i).path,
p_c006 => secure,
p_c007 => apex_web_service.g_response_cookies(i).version );
END LOOP;
END;
DECLARE
i number;
BEGIN
apex_collection.create_or_truncate_collection('P31_RESP_HEADERS');
FOR i in 1.. apex_web_service.g_headers.count LOOP
apex_collection.add_member(p_collection_name => 'P31_RESP_HEADERS',
p_c001 => apex_web_service.g_headers(i).name,
p_c002 => apex_web_service.g_headers(i).value,
p_c003 => apex_web_service.g_status_code);
END LOOP;
END;
Parent topic: About the APEX_WEB_SERVICE API