Oracle 18c PL/SQL调用HTTPS接口遇ORA-28759文件打开失败求助
解决Oracle 18c PL/SQL调用HTTPS时的ORA-28759错误
针对你遇到的ORA-28759: failure to open file despite permissions错误,以下是具体的排查和解决步骤:
1. 检查钱包路径的可访问性
你当前使用的是Z盘(网络映射盘)路径,Oracle数据库服务默认运行在Local System账户下,无法访问用户映射的网络驱动器。需要将钱包迁移到本地磁盘的固定路径,比如C:\oracle\wallets,同时注意路径格式:
- Windows环境下,Oracle路径需使用正斜杠(
/)或双反斜杠(\\),避免单斜杠转义问题 - 若使用auto_login类型钱包,只需指定文件夹路径,无需具体文件名
2. 确认数据库服务账户的权限
即使你给当前用户设置了权限,Oracle服务的登录账户如Local System或自定义账户需要对钱包文件夹及文件拥有读取权限:
- 打开Windows服务,找到
OracleService<你的SID>服务,查看其登录身份 - 右键钱包文件夹 → 属性 → 安全 → 添加该服务账户,授予「读取和执行」权限
3. 重新生成合规的钱包
确保钱包包含目标HTTPS站点的根证书,且为auto_login类型无需密码即可访问:
# 创建auto_login钱包 orapki wallet create -wallet C:\oracle\wallets -pwd YourWalletPassword -auto_login # 添加根证书比如Google的根证书 orapki wallet add -wallet C:\oracle\wallets -pwd YourWalletPassword -trusted_cert -cert C:\path\to\root_ca.crt
生成后会自动创建cwallet.ssoauto_login文件和ewallet.p12文件。
4. 修改PL/SQL代码
调整钱包路径配置,并完善响应读取逻辑避免只读取部分内容:
set serveroutput on size 30000; declare v_req utl_http.req; v_res utl_http.resp; v_buffer varchar2(4000); begin -- 使用auto_login钱包,只需指定文件夹路径,无需密码 utl_http.set_wallet('file:C:/oracle/wallets'); -- 发起HTTPS请求 v_req := utl_http.begin_request('https://www.google.com/'); v_res := utl_http.get_response(v_req); -- 循环读取完整响应内容 loop utl_http.read_text(v_res, v_buffer, 4000); dbms_output.put_line(v_buffer); end loop; exception when utl_http.end_of_body then utl_http.end_response(v_res); dbms_output.put_line(chr(10) || '------------------------'); dbms_output.put_line('状态码: ' || v_res.status_code); dbms_output.put_line('响应描述: ' || v_res.reason_phrase); when others then utl_http.end_response(v_res); raise; end; /
5. 检查代理配置如果是企业环境
若你的环境需要代理访问外网,需添加UTL_HTTP代理设置:
utl_http.set_proxy('proxy.yourcompany.com:8080', 'www.google.com');
内容的提问来源于stack exchange,提问作者elongez
相关产品推荐
相关产品推荐

