我有一个返回JSON格式数据的Web服务(超过4M个字符)。我想将该数据检索到Oracle表中。
这是我在PL SQL中与Web服务通信的过程:
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"}
所以我的问题是:
1.为什么我收到400错误请求错误?
1.为什么我不能把整个json拉出来?
2条答案
按热度按时间eufgjt7s1#
我在过去使用过以下代码来处理SOAP请求。
也许你可以改变它来满足你的需要。
9rygscc12#
对于超过32K的数据,我也得到了同样的错误。将“buffer”类型更改为clob在我的11.2.0.3.0数据库中没有任何效果。但是更改
至
是解决这个问题的方法。