我的任务是提供一个解决方案,将Oracle 10中的JSON对象交付到云中的web服务。我将使用PL/JSON来生成JSON对象,问题出在所需解决方案的交付方面。Oracle内部是否有使用PL/SQL将JSON对象交付到云的功能(这是我非常喜欢的方法)?或者我是否需要求助于Java之类的外部服务来提供此功能?一些示例代码/伪代码将非常受欢迎。
附言:我对网络技术的接触很少,所以请温文点:-)
关于Paul J。
发布于 2015-11-20 19:11:45
您需要使用utl_http包
下面是一个很好的示例,演示了如何将json字符串从pl/sql发送到web服务invoke-a-rest-service-from-plsql
begin
publish_cinema_event('2', -4);
end;
create or replace
procedure publish_cinema_event
( p_room_id in varchar2
, p_party_size in number
) is
req utl_http.req;
res utl_http.resp;
url varchar2(4000) := 'http://localhost:9002/cinema';
name varchar2(4000);
buffer varchar2(4000);
content varchar2(4000) := '{"room":"'||p_room_id||'", "partySize":"'||p_party_Size||'"}';
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.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 publish_cinema_event;https://stackoverflow.com/questions/33825051
复制相似问题