Utl_http яаж ашиглах вэ?


#1

Энэ энгийн жишээ ажилахгүй юм янз янзаар л үзлээ. Response нь хамаагүй зүгээр нэг ssl-гүй линк ажиллуулаал болох Task байгаа юм.

SELECT utl_http.request(‘http://www.oracle.com/’) FROM dual;

ORA-29273: HTTP request failed
ORA-06512: at “SYS.UTL_HTTP”, line 1722
ORA-12545: Connect failed because target host or object does not exist
ORA-06512: at line 1
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.


#2
begin 
dbms_network_acl_admin.create_acl ( 
acl => 'utl_http.xml', 
description => 'HTTP Access', 
principal => 'myuser', 
is_grant => TRUE, 
privilege => 'connect', 
start_date => null, 
end_date => null 
); 
commit;
dbms_network_acl_admin.add_privilege ( 
acl => 'utl_http.xml', 
principal => 'myuser', 
is_grant => TRUE, 
privilege => 'resolve', 
start_date => null, 
end_date => null 
); 
commit;
dbms_network_acl_admin.assign_acl ( 
acl => 'utl_http.xml', 
host => '199.101.28.18', 
lower_port => null, 
upper_port => null
); 
commit; 
end; 

иймэрхүү байдлаар тохируулсан


#3

Юуны өмнө firewall нтэрээ шалгаарай.
Мөн https://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:9526497800346930725 -ийг нэг харчих.


#4

Болчихлоо

grant execute on utl_http to MYUSER;
begin 
dbms_network_acl_admin.create_acl ( 
acl => 'utl_http.xml', 
description => 'HTTP Access', 
principal => 'MYUSER', 
is_grant => TRUE, 
privilege => 'connect', 
start_date => null, 
end_date => null 
); 
commit;
dbms_network_acl_admin.add_privilege ( 
acl => 'utl_http.xml', 
principal => 'MYUSER', 
is_grant => TRUE, 
privilege => 'resolve', 
start_date => null, 
end_date => null 
); 
commit;
dbms_network_acl_admin.assign_acl ( 
acl => 'utl_http.xml', 
host => '111.111.111.111', 
lower_port => 80, 
upper_port => 80
); 
commit; 
end; 
SET DEFINE OFF
select utl_http.request('http://111.111.111.111/api.php?id=1&par1=111') from dual;

гэж SQL дээрээсээ дуудаж ажилуулах юм байна. SET DEFINE OFF нь escape ampersand oracle sql хийгээд явуулж байна