我运行此代码时遇到此代码我收到凭据错误。如何提供凭据。身份验证设置为https页面中的窗口。弹出窗口将显示获取凭据
declare
req UTL_HTTP.REQ;
resp UTL_HTTP.RESP;
value varchar2(1024);
p_url varchar2(4000);
OPT varchar2(1000);
BEGIN
dbms_output.put_line('');
p_url:='http://www.xyz.com/';
dbms_output.put_line(p_url);
req := UTL_HTTP.begin_REQUEST(p_url);
utl_http.set_header(req, 'User-Agent', 'Mozilla/4.0');
resp := utl_http.get_response(req);
loop
utl_http.read_line(resp, value, true);
dbms_output.put_line(value);
end loop;
exception
when utl_http.end_of_body then
utl_http.end_response(resp);
END;
当我运行时,我得到了
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>401 - Unauthorized: Access is denied due to invalid credentials.</title>
<style type="text/css">
答案 0 :(得分:2)
您有两个选择(假设远程服务器接受HTTP基本身份验证):
p_url:='http://username:password@www.xyz.com/';
)utl_http.set_header(req, 'Authorization', 'Basic ' || utl_encode.base64_encode('username:password'));
)