📅  最后修改于: 2023-12-03 15:18:09.084000             🧑  作者: Mango
UTL_DBWS HTTPS is a package provided by Oracle to enable interaction with web services over HTTPS protocol from within the database.
To use UTL_DBWS HTTPS, follow these steps:
DECLARE
dbws_utl_loaded BOOLEAN;
BEGIN
SELECT 'TRUE' INTO dbws_utl_loaded FROM dual WHERE EXISTS (
SELECT * FROM all_objects WHERE object_type = 'PACKAGE BODY' AND object_name = 'UTL_DBWS'
);
IF dbws_utl_loaded THEN
DBMS_OUTPUT.PUT_LINE('Package already loaded');
ELSE
EXECUTE IMMEDIATE 'BEGIN DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE(
host => ''www.example.com'',
ace => xs\$ace_type(privilege_list => xs\$name_list('''|| user ||'''),
principal_name => '''' || user || '''',
is_grant => TRUE,
privilege => xs\$name_list('connect')
));
END;';
UTL_HTTP.ADD_CERTIFICATE(
'file:/path/to/cert',
'password'
);
UTL_DBWS.LOAD_WSDL('https://www.example.com/Service.wsdl');
DBMS_OUTPUT.PUT_LINE('Package loaded successfully');
END IF;
END;
/
This code does the following:
DECLARE
req UTL_DBWS.REQUEST;
res UTL_DBWS.RESPONSE;
BEGIN
req := UTL_DBWS.NEW_REQUEST('https://www.example.com/Service');
UTL_DBWS.SET_SOAP_VERSION(req, UTL_DBWS.SOAP_1_1);
UTL_DBWS.SET_BODY_STYLE(req, 'BARE');
UTL_DBWS.SET_HEADER(req, 'SOAPAction', 'http://www.example.com/Service#GetInfo');
UTL_DBWS.ADD_PARAMETER(req, 'arg1', 'value1');
UTL_DBWS.ADD_PARAMETER(req, 'arg2', 'value2');
res := UTL_DBWS.INVOKE(req);
UTL_DBWS.PRINT_RESPONSE(res);
END;
This code does the following:
UTL_DBWS HTTPS provides a convenient way to interact with web services over HTTPS protocol from within the database. By following the usage steps outlined above, you can easily configure and use this package in your Oracle applications.