0
我有一个以json格式(超过4M字符)返回数据的Web服务。 我想将这些数据检索到oracle表中。尝试从PL SQL调用Web服务时出现问题
这是我在PL SQL程序与Web服务comunicates:
CREATE OR REPLACE PROCEDURE SGS_CRM.SP_REST_POZIV AS
req utl_http.req;
res utl_http.resp;
url varchar2(32767) := 'http://10.200.24.60/facebook_app/posts/list/';
name varchar2(32767);
buffer CLOB;--varchar2(32767);
content varchar2(32767);
begin
req := utl_http.begin_request(url, 'POST',' 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.set_header (req, 'Transfer-Encoding', 'chunked');
UTL_HTTP.SET_BODY_CHARSET('UTF-8');
--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, TRUE);
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);
when utl_http.too_many_requests
then
utl_http.end_response(res);
end;
end SP_REST_POZIV;
这是我得到的错误:
[Error] Execution (1: 1): ORA-29273: HTTP request failed
ORA-06512: at "SYS.UTL_HTTP", line 1491
ORA-06502: PL/SQL: numeric or value error
ORA-06512: at "SGS_CRM.SP_REST_POZIV", line 24
ORA-06512: at line 2
当我限制JSON数据要小于4000字符我得到这个作为响应:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
<hr>
<address>Apache/2.2.15 (CentOS) Server at 10.200.24.60 Port 80</address>
</body></html>
{"id":"1","page_id":"199186763567391","message":"Kupujete stan? Pro\u0161le godine smo odobrili oko 25% vi\u0161e stambenih kredita nego prethodne, a ove godine nastavljamo istim trendom!\n\nNe znate \u0161ta vam je slede\u0107i korak? Iskoristite povoljan trenutak i prijavite se za besplatne konsultacije sa na\u0161im stru\u010dnjacima: http:\/\/stambeni-krediti.societegenerale.rs\/","link":"http:\/\/www.b92.net\/biz\/pr\/pr.php?nav_category=1244&yyyy=2017&nav_id=1250334","permalink_url":"https:\/\/www.facebook.com\/societegenerale.rs\/posts\/812151465604248","created_time":"2017-04-18 18:00:18","type":"link","name":"Ve\u0107a potra\u017enja za stambenim kreditima u pro\u0161loj godini - B92.net","post_id":"199186763567391_812151465604248","shares":"1","likes":"33","userlike_id":"435025440181160","userlike_name":"Zorica Stevanovic"}
所以我的问题是:
- 为什么我会收到400错误的请求错误?
- 为什么我不能拉整个json?