Xref: alice comp.databases.oracle.server:83157 Path: alice!news-feed.fnsi.net!newspump.monmouth.com!newspeer.monmouth.com!newshub.northeast.verio.net!verio!newsfeed.concentric.net!global-news-master From: Mohamed Buhari Newsgroups: comp.databases.oracle.server Subject: Re: utl_http.request Date: 02 Feb 2000 19:39:56 EST Organization: Assign Corp Lines: 160 Message-ID: <3898CE36.97E8EBF9@assigncorp.com> References: <3898C7F3.24192FE6@americasm97.nt.com> Reply-To: mbuhari@assigncorp.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.7 [en] (WinNT; U) X-Accept-Language: en 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 1. For this example, create the following: a. A new DAD called test_icx. i. Username: test_icx ii. Password: test_icx iii. SID or SQL*NET service depending on your system. iv. Check the options Create Database User and Store the username and password in the DAD. If user already exists, then only store the username and password. v. Enter the DBA username and password. b. A new PL/SQL agent called test_icx. i. DAD to be used: test_icx ii. Authorized ports: a non-administrative listener iii. Check Install Oracle Application Server Developer's Toolkit PL/SQL Packages. iv. Enter the DBA username and password. (Submit the new agent and give it a few minutes to install all the PL/SQL packages) c. Set up Perl Cartridge. i. In the Virtual Paths section, make sure the following virtual paths exist: /sample/perl ii. In the Physical path section, make sure the following physical path corresponds to the above virtual path: %ORAWEB_HOME%/sample/perl 2. For this example, check the following: a. hello.pl is installed in the following directory: i. NT: %ORACLE_HOME%\ows\3.0\sample\perl ii. UNIX: %ORACLE_HOME%/ows/3.0/sample/perl b. If hello.pl is not installed in this directory, please create the following code and name the file hello.pl. Place it in the above directory. print "Content-type: text/html\n\n"; print ""; print "Perl Cartridge - Hello World"; print ""; print "
"; print "

"; print "

Perl Cartridge - Hello World

"; print "

"; print "


"; print "Hello, World of Cartridges
"; $remote_host = $ENV{'REMOTE_HOST'}; print "\nHi, User at ", $remote_host, "
" ; print "I am responding from the Perl Cartridge!!
"; print "

"; print "


"; print "
(C) Oracle Corporation, 1996
"; print ""; print ""; Procedure 1. In test_icx's schema, create the following 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; END test_icx; / Calling the procedure 1. Start a browser. Use the following URL: 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 > > #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", "\n" ); > printf( "%s", "\n" ); > printf( "%s", "Show Log '$command'\n" ); > printf( "%s", "\n" ); > printf( "%s", "

Show Log '$command'

\n" ); > printf( "%s", "
\n" );
>         printf( "%s", "$results\n" );
>         fflush(stdout);
>
>     exit( 0 );
> }