43.4 Retrieving Cookies and HTTP Headers
When you invoke a Web service using any of the supported methods in Application Express, 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 Application Express, 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: APEX_WEB_SERVICE