oracle请求http接口

oracle的存储过程直接调用http接口

declare
req utl_http.REQ;
resp utl_http.RESP;
xmlstr CLOB;
begin
req  := utl_http.BEGIN_REQUEST('http://192.168.1.200:9090/test','POST');
utl_http.set_header(req, 'Content-Type','application/x-www-form-urlencoded');      --该参数代表请求包含POST数据
utl_http.set_header(req, 'Keep-Alive', '  timeout=1');--该参数代表超时
xmlstr :='msg=3c726f6f743ee5be80e5af9de5aea42525252424242424c2a5c2a5c2a5c2a5c2a53c2f726f6f743e';
utl_http.set_header(req, 'Content-Length', dbms_lob.getlength(xmlstr));--该参数代表我发送的POST报文多长,不可少
utl_http.write_text(req,xmlstr);
resp := utl_http.get_response(req);
utl_http.end_response(resp);
end;

其中3c726f6f743ee5be80e5af9de5aea42525252424242424c2a5c2a5c2a5c2a5c2a53c2f726f6f743e

是要发送的数据通过16进制编码后的字符串(可以使用Hutool工具类库的HexUtill.encodeHexStr)

Guess you like

Origin blog.csdn.net/muguku/article/details/119932634