致电(消费)Oracle 12C PL/SQL中的Web服务
我正在尝试调用/消耗返回静态字符串的Web服务。下面的代码在执行时会引发错误(下面滚动)。感谢帮助。
Oracle版本:12.2.0.1
设置了Oracle钱包 的执行特权
utl_http,utl_smtp,utl_tcp扰乱了URL
CREATE OR REPLACE FUNCTION WS_TST
RETURN VARCHAR2
IS
v_req UTL_HTTP.req;
v_resp UTL_HTTP.resp;
v_msg VARCHAR2 (32767);
v_entire_msg VARCHAR2 (32767) := NULL;
v_RR NUMBER;
v_wallet_path VARCHAR2 (32767);
--v_url VARCHAR2(32767) := 'https://dcaopppm.com/RecalcSer/api/AT/RR?stat=3&Do=01/01/2015&SType=P&Dob=01/01/1990';
BEGIN
v_wallet_path := 'file:/u01/app/oracle/admin/DEVDBINST/wallet';
UTL_HTTP.set_wallet (v_wallet_path, NULL);
v_req := UTL_HTTP.begin_request (url => v_url, method => 'GET');
v_resp := UTL_HTTP.get_response (r => v_req);
BEGIN
LOOP
UTL_HTTP.read_text (r => v_resp, data => v_msg);
v_entire_msg := v_entire_msg || v_msg;
DBMS_OUTPUT.PUT_LINE ('v_entire_msg: ' || v_entire_msg);
END LOOP;
EXCEPTION
WHEN UTL_HTTP.end_of_body
THEN
NULL;
END;
v_entire_msg := REPLACE (v_entire_msg, CHR (13));
v_entire_msg := REPLACE (v_entire_msg, CHR (10));
v_entire_msg :=
REPLACE (v_entire_msg, '<?xml version="1.0" encoding="utf-8"?>');
v_entire_msg :=
REPLACE (v_entire_msg,
'<double xmlns="http://www.webservicex.net/">');
v_entire_msg := REPLACE (v_entire_msg, '</double>');
DBMS_OUTPUT.put_line ('v_entire_msg: ' || v_entire_msg);
BEGIN
v_RR := TO_CHAR (v_entire_msg);
EXCEPTION
WHEN OTHERS
THEN
v_RR := NULL;
END;
UTL_HTTP.end_response (r => v_resp);
RETURN v_RR;
END WS_TST;
,实际URL确实在执行后返回静态字符串错误:
Error at line 1
ORA-29273: HTTP request failed
ORA-28759: failure to open file
ORA-06512: at "SYS.UTL_HTTP", line 380
ORA-06512: at "SYS.UTL_HTTP", line 1127
I'm trying to call/consume a web service that returns a static string. The below code throws an error (scroll below) on execution. Appreciate help.
Oracle Version: 12.2.0.1
Oracle wallet is setup
Execute privileges exists for UTL_HTTP, UTL_SMTP, UTL_TCP
Scrambled the URL, the actual URL does return the static string
CREATE OR REPLACE FUNCTION WS_TST
RETURN VARCHAR2
IS
v_req UTL_HTTP.req;
v_resp UTL_HTTP.resp;
v_msg VARCHAR2 (32767);
v_entire_msg VARCHAR2 (32767) := NULL;
v_RR NUMBER;
v_wallet_path VARCHAR2 (32767);
--v_url VARCHAR2(32767) := 'https://dcaopppm.com/RecalcSer/api/AT/RR?stat=3&Do=01/01/2015&SType=P&Dob=01/01/1990';
BEGIN
v_wallet_path := 'file:/u01/app/oracle/admin/DEVDBINST/wallet';
UTL_HTTP.set_wallet (v_wallet_path, NULL);
v_req := UTL_HTTP.begin_request (url => v_url, method => 'GET');
v_resp := UTL_HTTP.get_response (r => v_req);
BEGIN
LOOP
UTL_HTTP.read_text (r => v_resp, data => v_msg);
v_entire_msg := v_entire_msg || v_msg;
DBMS_OUTPUT.PUT_LINE ('v_entire_msg: ' || v_entire_msg);
END LOOP;
EXCEPTION
WHEN UTL_HTTP.end_of_body
THEN
NULL;
END;
v_entire_msg := REPLACE (v_entire_msg, CHR (13));
v_entire_msg := REPLACE (v_entire_msg, CHR (10));
v_entire_msg :=
REPLACE (v_entire_msg, '<?xml version="1.0" encoding="utf-8"?>');
v_entire_msg :=
REPLACE (v_entire_msg,
'<double xmlns="http://www.webservicex.net/">');
v_entire_msg := REPLACE (v_entire_msg, '</double>');
DBMS_OUTPUT.put_line ('v_entire_msg: ' || v_entire_msg);
BEGIN
v_RR := TO_CHAR (v_entire_msg);
EXCEPTION
WHEN OTHERS
THEN
v_RR := NULL;
END;
UTL_HTTP.end_response (r => v_resp);
RETURN v_RR;
END WS_TST;
Error upon execution:
Error at line 1
ORA-29273: HTTP request failed
ORA-28759: failure to open file
ORA-06512: at "SYS.UTL_HTTP", line 380
ORA-06512: at "SYS.UTL_HTTP", line 1127
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,问题在这两行中:
请确保您的钱包实际上是在此存储库中。请记住,这应该指向钱包所在的文件夹,而不是钱包文件本身。还要确保钱包文件命名为
ewallet.p12
。如果一切都到位,请确保您实际上没有钱包上有密码。
最后,我想到的是您的数据库无法读取此文件夹。尝试还授予此文件夹上的读取权限。
这是我过去对我有用的。是否有效,请返回反馈!祝你好运!
Well the issue is in these two lines:
Please ensure that your wallet is in fact in this repository. Keep in mind that this should point to the folder where the wallet is located and not the wallet file itself. Also make sure that the wallet file is named
ewallet.p12
.If all is in place, please ensure that you do not in fact have a password on the wallet.
Lastly what comes to my mind is that your DB is unable to read this folder. Try to also grant read permissions on this folder.
This is what worked in the past for me. Please do come back with feedback whether it worked! Best of luck!