Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

error in utl_http

806193Oct 20 2010
Hi

I am trying to request using utl_http pacakage with oracle 10g.


Below is the codesnipple.


create or replace
PROCEDURE Proc_test
(
url IN VARCHAR2,
username IN VARCHAR2 DEFAULT NULL,
pwd IN VARCHAR2 DEFAULT NULL
) AS
req utl_http.req;
resp utl_http.resp;
name VARCHAR2(256);
value VARCHAR2(1024);
data VARCHAR2(255);
my_scheme VARCHAR2(256);
my_realm VARCHAR2(256);
my_proxy BOOLEAN;
BEGIN
-- When going through a firewall, pass requests through this host.
-- Specify sites inside the firewall that don't need the proxy host.
utl_http.set_proxy('192.168.104.31:8080', '');

-- Ask UTL_HTTP not to raise an exception for 4xx and 5xx status codes,
-- rather than just returning the text of the error page.
utl_http.set_response_error_check(FALSE);

-- Begin retrieving this web page.
req := utl_http.begin_request('url');

-- Identify ourselves. Some sites serve special pages for particular browsers.
utl_http.set_header(req, 'User-Agent', 'Mozilla/4.0');
utl_http.set_transfer_timeout(180);

-- Specify a user ID and password for pages that require them.
IF (username IS NOT NULL) THEN
utl_http.set_authentication(req, username, pwd);
END IF;

BEGIN
-- Now start receiving the HTML text.
resp := utl_http.get_response(req);

-- Show the status codes and reason phrase of the response.
dbms_output.put_line('HTTP response status code: ' || resp.status_code);
dbms_output.put_line('HTTP response reason phrase: ' || resp.reason_phrase);

-- Look for client-side error and report it.
IF (resp.status_code >= 400) AND (resp.status_code <= 499) THEN

-- Detect whether the page is password protected, and we didn't supply
-- the right authorization.
IF (resp.status_code = utl_http.HTTP_UNAUTHORIZED) THEN
utl_http.get_authentication(resp, my_scheme, my_realm, my_proxy);
IF (my_proxy) THEN
dbms_output.put_line('Web proxy server is protected.');
dbms_output.put('Please supply the required ' || my_scheme ||
' authentication username/password for realm ' || my_realm ||
' for the proxy server.');
ELSE
dbms_output.put_line('Web page ' || url || ' is protected.');
dbms_output.put('Please supplied the required ' || my_scheme ||
' authentication username/password for realm ' || my_realm ||
' for the Web page.');
END IF;
ELSE
dbms_output.put_line('Check the URL.');
END IF;

utl_http.end_response(resp);
RETURN;

-- Look for server-side error and report it.
ELSIF (resp.status_code >= 500) AND (resp.status_code <= 599) THEN

dbms_output.put_line('Check if the Web site is up.');
utl_http.end_response(resp);
RETURN;

END IF;

-- The HTTP header lines contain information about cookies, character sets,
-- and other data that client and server can use to customize each session.
FOR i IN 1..utl_http.get_header_count(resp) LOOP
utl_http.get_header(resp, i, name, value);
dbms_output.put_line(name || ': ' || value);
END LOOP;

-- Keep reading lines until no more are left and an exception is raised.
LOOP
utl_http.read_line(resp, value);
dbms_output.put_line(value);
END LOOP;
EXCEPTION
WHEN utl_http.end_of_body THEN
--utl_http.get_detailed_sqlerrm(resp);
dbms_output.put_line('error:'||sqlerrm);
utl_http.end_response(resp);

END;

END;




while executing the sql query

set serveroutput on
exec test('http://www.oracle.com','isecuretest','isecuretest');


I am getting the error
ORA-29273: HTTP request failed
ORA-06512: at "SYS.UTL_HTTP", line 1231
ORA-29263: HTTP protocol error
ORA-06512: at "ISECURETEST.TEST", line 38
ORA-06512: at line 10.


please help me to sort the issues..

thanks in advance,
sasi
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 17 2010
Added on Oct 20 2010
0 comments
398 views