Re: utl_http.request: HTTP request failed

From: shakespeare <whatsin_at_xs4all.nl>
Date: Fri, 25 Jan 2008 20:58:15 +0100
Message-ID: <479a3f5a$0$85783$e4fe514c@news.xs4all.nl>

"KevinS" <SearleK_at_googlemail.com> schreef in bericht news:851047ce-16d0-46a1-b8e5-f846bdc70783_at_s13g2000prd.googlegroups.com...
> Hello,
>
> A utl_http.request('URL') call in a procedure is failing with the
> message
>
> ORA-29273: HTTP request failed
> ORA-06512: at "SYS.UTL_HTTP", line 1568
> ORA-12545: Connect failed because target host or object does not
> exist
>
> If I paste the url in a web browser I get a response so why is it
> failing when being launched from the database?
>
> The problem occurs when I use the machine name and when I use the
> machines IP address.
>
> Any idea's what the cause might be?
>
> The version of Oracle being run is 10.2.0.2.0.
>
> Thanks

utl_http.request is called at the server, not at the client. So you may have to fill one of the parameters with a proxy address (like proxy.yourdomain.com:8080). If your browser uses a proxy, you should do the same with your procedure. As I recall, it's the second parameter. Btw: this function only returns a part of large pages... If you want to fetch the complete page, you could use something like (this is only partial code...)

req utl_http.req;
resp utl_http.resp;
begin

   utl_http.set_detailed_excp_support(TRUE);
   utl_http.set_follow_redirect(no_of_redirects);
   utl_http.set_cookie_support(TRUE);
   utl_http.set_proxy(l_proxy_url);

   req := utl_http.begin_request(url);
   utl_http.set_header(req,'User-Agent',owa_util.get_cgi_env('HTTP_USER_AGENT'));    resp := utl_http.get_response(req);
   LOOP
      utl_http.read_line(resp, VALUE, TRUE);
      htp.p(VALUE);  -- or some way of storing/showing the result
   END LOOP;
   utl_http.end_response(resp);
end;

Shakespeare Received on Fri Jan 25 2008 - 13:58:15 CST

Original text of this message