Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: utl_http.request
Here is an example :
The package, utl_http comes with the Enterprise Server. A useful
procedure
inside this package, request, displays HTML for a certain URL and can be
used
inside of a PL/SQL procedure.
The exact call is utl_http.request.
The following steps are an example of how to get this procedure to work
for
Oracle Application Server 3.0 in a PL/SQL Procedure. Please read
through this
bulletin before attempting to execute it.
SCOPE & APPLICATION Setting up Cartridges
print "Content-type: text/html\n\n"; print "<html>"; print "<head><title>Perl Cartridge - Hello World</title></head>"; print "<body BACKGROUND=\"/ows-img/orhmbkgn.jpg\" text=\"#000088\">"; print "<hr noshade>"; print "<p>"; print "<h1>Perl Cartridge - Hello World</h1>"; print "<p>"; print "<hr noshade>"; print "Hello, World of Cartridges<br>"; $remote_host = $ENV{'REMOTE_HOST'}; print "\nHi, User at ", $remote_host, "<br>" ; print "I am responding from the Perl Cartridge!!<br>"; print "<p>"; print "<hr noshade>"; print "<address>(C) Oracle Corporation, 1996</address>"; print "</body>"; print "</html>";
Procedure
CREATE OR REPLACE PROCEDURE test_icx
IS
resp varchar2(2000);
BEGIN
htp.htmlOpen; htp.bodyOpen; htp.bold('Test ICX - w/ plsql first'); htp.br; htp.para; htp.p('This first section is PL/SQL code'); htp.para; htp.p('The following section is coming from the Perl Cartridge'); htp.br; SELECT utl_http.request('http://host.domain:port/sample/perl/hello.pl') INTO resp FROM dual; htp.p(resp); htp.br; htp.br; htp.bold('Now you see how to insert perl inside of your PL/SQL procedure!'); htp.br; htp.bodyClose; htp.htmlClose;
Calling the procedure
http://hostname:port/test_icx/plsql/test_icx
"Lockie, Bob" wrote:
> Help.
>
> exec :res := utl_http.request( 'http://localhost:2000/httptest.cgi' );
> Fails when calling a pseudo web server (something that listens on port
> 2000 via inetd).
>
> The following is my "server" code.
> I can't seem to get it right.
> What is the proper response for a web server?
> I think Oracle is looking for that.
>
> #include <stdio.h>
>
> #define MAXLINELEN 1024
>
> main(int argc, char *argv[ ], char *envp[ ])
> {
> char szLine[MAXLINELEN];
>
> printf( "Content-type: text/html\n\r" );
> printf( "HTTP/1.1 200 npauth request\n\r" );
> printf( "Server: Pseudo\n\r" );
>
> fflush( stdout );
>
> fgets( szLine, MAXLINELEN, stdin );
>
> printf( "%s", "<HTML>\n" );
> printf( "%s", "<HEAD>\n" );
> printf( "%s", "<TITLE>Show Log '$command'</TITLE>\n" );
> printf( "%s", "</HEAD>\n" );
> printf( "%s", "<H1>Show Log '$command'</H1>\n" );
> printf( "%s", "<PRE>\n" );
> printf( "%s", "$results\n" );
> fflush(stdout);
>
> exit( 0 );
> }
Received on Wed Feb 02 2000 - 18:39:56 CST