oracle wallet

    oracle在使用utl_http包读取某个url连接的内容时,对于http协议与https协议的url两者的处理是截然不同的,上两篇文章已经有使用http的啦,而https是加密的协议,所以需要用到oracle的wallet manager管理模块,wallet顾名思义就是钱包钱袋的管理,说白了就是安全管理(钱包、钱袋)吗^_^
  下面我们就简单学习下oracle wallet manager(针对utl_http包的使用)
首先要使用utl_http包抓取htttps上的内容,需要UTL_HTTP.SET_WALLET (
path IN VARCHAR2,
password IN VARCHAR2 DEFAULT NULL);
那么在设置wallet前我们的步骤是:
第一.创建wallet目录
[oracle@localhost wallet]$ mkdir wallet
第二.新建wallet
[oracle@localhost wallet]$ orapki wallet create -wallet /home/oracle/wallet -pwd wallet
第三.导入受信任的https安全证书
[oracle@localhost wallet]$ orapki wallet add -wallet /home/oracle/wallet -trusted_cert -cert /home/oracle/wallet/CA_cert.cer

到此针对utl_http包获取https网页内容的配置就可以了


不过对于oracle的utl_http包处理https数据还是不是很灵活,会遇到不同的问题!

create or replace procedure get_realtime_account_data is
  req UTL_HTTP.REQ;
  resp UTL_HTTP.RESP;
  val varchar2(2000);
  real_records datacenter.common_utils.STRING_LIST;
  fields datacenter.common_utils.STRING_LIST;
  d_date date := to_date(to_char(sysdate, 'yyyy-mm-dd hh24:mi') ||
                               ':00',
                               'yyyy-mm-dd hh24:mi:ss');
begin
  UTL_HTTP.SET_WALLET('file:/home/oracle/wallet', 'wallet');
  req := UTL_HTTP.BEGIN_REQUEST('https://192.168.127.1/GameMaster/GetServerInfo.aspx');
  resp := UTL_HTTP.GET_RESPONSE(req);
  utl_http.read_line(resp, val, true);
  utl_http.end_response(resp);
  real_records := datacenter.common_utils.EXPLODE(val, '|');

  for i in 1 .. real_records.count loop
    fields := datacenter.common_utils.EXPLODE(real_records(i), '/');
    insert into stat_realtime_player_count
    values
      (d_date, fields(1), '', fields(2));
  end loop;
  commit;
EXCEPTION
  WHEN utl_http.end_of_body THEN
    utl_http.end_response(resp);
end get_realtime_account_data;


作者: hero--008   发布时间: 2010-11-08