Oracle HTTP请求接收! .

create or replace procedure p_sendsms(l_type         in varchar2,
                                      l_phoneNo      in varchar2,
                                      l_content      in varchar2,
                                      l_err_code       out integer,
                                      l_ora_code       out integer) is
  l_respond varchar2(4000); --响应报文
  http_req  utl_http.req; --请求包头
  http_resp utl_http.resp; --响应包头
BEGIN
http_req := utl_http.begin_request('http:senderServlet?mobiles=' ||
                                     l_phoneNo || '&content=' || l_content ||
                                     '&type=' || l_type,
                                     'POST',
                                     utl_http.HTTP_VERSION_1_1 /* 'HTTP/1.1'*/);
  utl_http.set_header(http_req,
                      'Content-Type',
                      'application/x-www-form-urlencoded;charset=utf-8');
  http_resp := utl_http.get_response(http_req); --提交请求

  if http_resp.status_code = utl_http.HTTP_OK then
    --成功才读取响应消息
    utl_http.read_text(http_resp, l_respond);
    utl_http.end_response(http_resp); --结束请求
    l_respond := substr(l_respond, 1, 4000); ---long 转成 varchar2
    dbms_output.put_line(l_respond); --打印响应消息
    dbms_output.put_line(http_resp.reason_phrase); --打印响应消息
  else
    l_err_code := http_resp.status_code;
    l_ora_code := sqlcode;
    dbms_output.put_line(http_resp.reason_phrase); --打印响应消息
  end if;
exception
  WHEN OTHERS THEN
    l_ora_code := sqlcode;
END;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值