我正在開發測試Oracle過程以從本地XAMPP託管的Web服務接收JSON對象。遵循以下步驟。通過PL/SQL中的Webservice處理JSON對象
(01)創建的ACL
set define off;
BEGIN
SYS.DBMS_NETWORK_ACL_ADMIN.CREATE_ACL(acl => 'www.xml',
description => 'TEST JSON',
principal => 'TEST_USER',
is_grant => true,
privilege => 'connect',
start_date => SYSTIMESTAMP,
end_date => NULL);
SYS.DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(acl => 'www.xml',
principal => 'TEST_USER',
is_grant => true,
privilege => 'resolve');
SYS.DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(acl => 'www.xml',
host => 'localhost',
lower_port => 8081,
upper_port => NULL);
END;
(02)以下是測試PROC
create or replace PROCEDURE JSON11 IS
l_param_list VARCHAR2(512);
l_http_request UTL_HTTP.req;
l_http_response UTL_HTTP.resp;
l_response_text VARCHAR2(32767);
l_list system.json_list;
acl VARCHAR2(100);
url VARCHAR2(1000) :=
'http://localhost:8081/PhpProjectFirst/displayValuesSent.php?
name=name11&[email protected]&gender=male&course=OCA2&class=2008&s
ubject=PL/SQL';
BEGIN
DBMS_OUTPUT.put_line('start');
l_http_request := utl_http.begin_request(url, 'POST','HTTP/1.1');
DBMS_OUTPUT.put_line('aa');
--utl_http.set_header(l_http_request, 'user-agent', 'mozilla/4.0');
utl_http.set_header(l_http_request, 'Content-Type', 'application/json');
--utl_http.set_header(l_http_request, 'Content-Length',
length(content));
--utl_http.write_text(l_http_request, content);
DBMS_OUTPUT.put_line('bb');
l_http_response := utl_http.get_response(l_http_request);
DBMS_OUTPUT.put_line('cc');
-- process the response from the HTTP call
begin
loop
utl_http.read_line(l_http_response, l_response_text);
dbms_output.put_line(l_response_text);
end loop;
utl_http.end_response(l_http_response);
end;
exception
when utl_http.end_of_body then
utl_http.end_response(l_http_response);
when others then
DBMS_OUTPUT.put_line('Error >> '||sqlerrm);
END JSON11;
(03)叫PROC
set serveroutput on size 30000;
BEGIN
JSON11();
END;
但以下面的錯誤結束。
Error >> ORA-29273: HTTP request failed
ORA-06512: at "SYS.UTL_HTTP", line 1130
ORA-29270: too many open HTTP requests
DB是Oracle XE並使用Oracle SQL Developer。 Webservice非常簡單,通過XAMPP運行並返回一個簡單的JSON對象。
任何提示可以共享?
問候, LM
爲什麼這個標籤爲'pljson'? –
我已經使用PL/JSON項目的JSON對象來引用Web服務。 –