Oracle错误ORA-28805:调用UTL_HTTP.request时无法从数据源检索信息

时间:2019-06-04 22:06:31

标签: oracle api https certificate oracle12c

我正在尝试使用Oracle UTL_HTTP.request API调用Web服务。通话需要代理和钱包/证书。我收到ORA-28805: Cannot retrieve information from the data source错误。我正在使用DBMS版本12.1.0.2.0和数据库PSU 12.1.0.2.160419。

以下 https 调用会引发ORA-28805错误:

DECLARE
  l_http_request utl_http.req;
  l_http_response utl_http.resp;
  l_text VARCHAR2(32767);
BEGIN
  utl_http.set_proxy('myproxy.url.com');
  utl_http.set_wallet('file:/my/wallet/location'
                      ,'mypass');
  -- HTTPS Request --
  l_http_request := utl_http.begin_request('https://app.myurl.com/myservice/','GET','HTTP/1.1');
  utl_http.set_header(l_http_request, 'Authorization', 'Token mytoken');
  l_http_response := utl_http.get_response(l_http_request);
  BEGIN
    LOOP
      utl_http.read_text(l_http_response, l_text, 32766);
      dbms_output.put_line(l_text);
    END LOOP;
  EXCEPTION WHEN utl_http.end_of_body THEN
    utl_http.end_response(l_http_response);
  END;
END;

运行时异常堆栈:

ORA-29273: HTTP request failed
ORA-28805: Cannot retrieve information from the data source.
ORA-06512: at "SYS.UTL_HTTP", line 368
ORA-06512: at "SYS.UTL_HTTP", line 1118
ORA-06512: at line 10

以下 http 调用可完美运行并返回JSON负载:

DECLARE
  l_http_request utl_http.req;
  l_http_response utl_http.resp;
  l_text VARCHAR2(32767);
BEGIN
  utl_http.set_proxy('myproxy.url.com');
  utl_http.set_wallet('file:/my/wallet/location'
                      ,'mypass');
  -- HTTP request --
  l_http_request := utl_http.begin_request('http://jsonplaceholder.typicode.com/todos/1','GET','HTTP/1.1');
  utl_http.set_header(l_http_request, 'Authorization', 'Token mytoken');
  l_http_response := utl_http.get_response(l_http_request);
  BEGIN
    LOOP
      utl_http.read_text(l_http_response, l_text, 32766);
      dbms_output.put_line(l_text);
    END LOOP;
  EXCEPTION WHEN utl_http.end_of_body THEN
    utl_http.end_response(l_http_response);
  END;
END;

响应:

{
  "userId": 1,
  "id": 1,
  "title": "delectus aut autem",
  "completed": false
}

我成功地将以下内容作为系统运行,但无法解决问题:

BEGIN
  DBMS_NETWORK_ACL_ADMIN.APPEND_WALLET_ACE
  (
    WALLET_PATH => 'file:/my/wallet/location',
    ACE => XS$ACE_TYPE(
                        PRIVILEGE_LIST => XS$NAME_LIST('use_client_certificates','use_passwords'),
                        PRINCIPAL_NAME => 'myuser',
                        PRINCIPAL_TYPE => XS_ACL.PTYPE_DB
                      )
  );
EXCEPTION WHEN OTHERS THEN
  DBMS_OUTPUT.PUT_LINE('Error while configuring ACL for wallet: '|| SQLERRM);
END;

关于什么可能导致此错误的任何想法?

1 个答案:

答案 0 :(得分:0)

我认为问题在于您同时使用了两种特权

https://docs.oracle.com/database/121/DBSEG/fine_grained_access.htm#DBSEG118

文档说:请注意,对于钱包,您必须指定use_client_certificates OR use_passwords特权。