我需要有关此代码的帮助,我收到错误消息说。
ORA-29273: HTTP request failed
ORA-12541: TNS:no listener
ORA-06512: at "SYS.UTL_HTTP", line 368
ORA-06512: at "SYS.UTL_HTTP", line 1118
ORA-06512: at line 5
29273. 00000 - "HTTP request failed"
*Cause: The UTL_HTTP package failed to execute the HTTP request.
*Action: Use get_detailed_sqlerrm to check the detailed error message.
Fix the error and retry the HTTP request.
我联系了网络团队,他们看到该端口上的双向流量正在完成,所以我不确定还有什么/可能是错的?任何想法?
create or replace
procedure Test_Rest_Call3
is
req utl_http.req;
res utl_http.resp;
url varchar2(4000) := 'http://ipaddresshere:9099/api/batchProcess/1';
name varchar2(4000);
buffer varchar2(4000);
content varchar2(4000) := '';
begin
req := utl_http.begin_request(url, 'DELETE',' HTTP/1.1');
utl_http.set_header(req, 'user-agent', 'mozilla/4.0');
utl_http.set_header(req, 'content-type', 'application/json');
utl_http.set_header(req, 'Content-Length', length(content));
utl_http.write_text(req, content);
res := utl_http.get_response(req);
-- process the response from the HTTP call
begin
loop
utl_http.read_line(res, buffer);
dbms_output.put_line(buffer);
end loop;
utl_http.end_response(res);
exception
when utl_http.end_of_body
then
utl_http.end_response(res);
end;
end Test_Rest_Call3;
答案 0 :(得分:0)
您是否检查过DBA是否已授权执行utl_http? 只需尝试运行它就可以确保:
select utl_http.request('http://ipaddresshere:9099/api/batchProcess/1') from dual;
如果遇到错误,请要求DBA给予相应的许可:
grant execute on utl_http to your_oracle_user_name
grant execute on dbms_lock to user_name
BEGIN
DBMS_NETWORK_ACL_ADMIN.create_acl (
acl => 'local_sx_acl_file.xml',
description => 'A test of the ACL functionality',
principal => 'put your user_name',
is_grant => TRUE,
privilege => 'connect',
start_date => SYSTIMESTAMP,
end_date => NULL);
end;
begin
DBMS_NETWORK_ACL_ADMIN.assign_acl (
acl => 'local_sx_acl_file.xml',
host => 'localhost',
lower_port => 9002,
upper_port => NULL);
end;
我希望它会有所帮助。
干杯
Morteza Fakoorrad