oracle存儲過程掉用HTTP接口

CREATE OR REPLACE PROCEDURE FSMT.P_GET_HTTP_RES
/*
描述:存儲過程掉用HTTP接口
作者:Janus
日期:2024-08-15
*/
(
M_DOC_NO IN VARCHAR2,  
M_DOC_TYPE IN VARCHAR2, 
M_STANDBY IN VARCHAR2,  
M_EMP IN VARCHAR2,  
RES OUT VARCHAR2 --返回值
)
AS
REQ utl_http.req;
RESP utl_http.resp;
V_LINE varchar2(4000);
V_TEXT varchar2(4000);
L_BODY varchar2(4000);
L_RES varchar2(200);
L_MSG varchar2(4000);
RESVALUE varchar2(200);
L_ADD varchar2(400);
BEGIN
L_BODY := ' {"msgid":"12313","usercode":"F2123404","show_notification_flag":1,"play_title_voice_flag":"1","Title":"123131   Janus ","content":"1231231 ","query_url":"http://10.14.14.38/assets/ad8bebfbfe627.jpg"}';
L_ADD:='http://112.16.3.82:18848/sys-message/send_alarm_ulist';
REQ := utl_http.begin_request(url =>L_ADD, method =>'POST');
-- utl_http.set_body_charset('UTF-8');
-- utl_http.set_header(req, 'Content-Type', 'text/html; charset=gb2312');text/html;;application/json
utl_http.SET_BODY_CHARSET(REQ,'UTF-8');
utl_http.set_header(REQ, 'Content-Type', 'application/json;charset=UTF-8;');
utl_http.set_header(REQ, 'Authorization', 'eyJ1eXAiOiJKV1QiLCJhbGciO1JIUzUx1iJ9.eyJzdWIiOiJGMjkwMzAwNCIsImlhdCI6MTcwMDQ3MTY0NCwiZXhwIjo3NzQ4NDcxNjQ0fQ.arfdRpFzQFfDC681dU4zWqjEe3CCCS1LGWEVuDi9_WS_r1aks2CG8ooNj-jyaCUWyvv_h9cHPohrblJjMuNc3A');
utl_http.set_header(REQ, 'Content-Length', lengthb(L_BODY));
utl_http.write_text(REQ, L_BODY);
RESP := utl_http.get_response(REQ);

utl_http.end_response(resp);
utl_http.end_request(req);

exception
when utl_http.end_of_body then
utl_http.end_response(RESP);

RETURN;
when others then
dbms_output.put_line(sqlerrm);
utl_http.end_response(resp);
utl_http.end_request(req);
RES := 'NG:' ||sqlerrm ;
RETURN;

end;

posted @ 2024-08-15 22:36  Janus2003  阅读(3)  评论(0编辑  收藏  举报