CONSUMIR SERVICIO REST DESDE ORACLE
CREATE STORE
create or replace PROCEDURE CONSUMIR_REST_SMS(IN_NUMERO IN VARCHAR2, IN_MENSAJE IN VARCHAR2) IS
request utl_http.req;
response utl_http.resp;
url VARCHAR2(4000) := 'http://10.10.10.8:8080/RSSMS/enviar.json';
name VARCHAR2(4000);
buffer VARCHAR2(4000);
content VARCHAR2(4000) := '{"numeroTelefonico":"' || IN_NUMERO || '", "mensaje":"' || IN_MENSAJE || '"}';
BEGIN
request := utl_http.begin_request(url, 'POST',' HTTP/1.1');
utl_http.set_header(request, 'user-agent', 'mozilla/4.0');
utl_http.set_header(request, 'content-type', 'application/json');
utl_http.set_header(request, 'Content-Length', length(content));
utl_http.write_text(request, content);
response := utl_http.get_response(request);
-- process the response from the HTTP call
BEGIN
LOOP
utl_http.read_line(response, buffer);
dbms_output.put_line('JAS' || buffer);
END LOOP;
utl_http.end_response(response);
EXCEPTION
WHEN utl_http.end_of_body
THEN
utl_http.end_response(response);
END;
END CONSUMIR_REST_SMS;
PERMISOS EN ORACLE
DBMS_NETWORK_ACL_ADMIN.ASSIGN_ ACL(acl=>'UTL_HTTP.xml',host=> '10.10.10.8');
CREATE STORE
create or replace PROCEDURE CONSUMIR_REST_SMS(IN_NUMERO IN VARCHAR2, IN_MENSAJE IN VARCHAR2) IS
request utl_http.req;
response utl_http.resp;
url VARCHAR2(4000) := 'http://10.10.10.8:8080/RSSMS/enviar.json';
name VARCHAR2(4000);
buffer VARCHAR2(4000);
content VARCHAR2(4000) := '{"numeroTelefonico":"' || IN_NUMERO || '", "mensaje":"' || IN_MENSAJE || '"}';
BEGIN
request := utl_http.begin_request(url, 'POST',' HTTP/1.1');
utl_http.set_header(request, 'user-agent', 'mozilla/4.0');
utl_http.set_header(request, 'content-type', 'application/json');
utl_http.set_header(request, 'Content-Length', length(content));
utl_http.write_text(request, content);
response := utl_http.get_response(request);
-- process the response from the HTTP call
BEGIN
LOOP
utl_http.read_line(response, buffer);
dbms_output.put_line('JAS' || buffer);
END LOOP;
utl_http.end_response(response);
EXCEPTION
WHEN utl_http.end_of_body
THEN
utl_http.end_response(response);
END;
END CONSUMIR_REST_SMS;
PERMISOS EN ORACLE
DBMS_NETWORK_ACL_ADMIN.ASSIGN_
Comentarios
Publicar un comentario