Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: utl_http.request

Re: utl_http.request

From: Mohamed Buhari <mbuhari_at_assigncorp.com>
Date: 02 Feb 2000 19:39:56 EST
Message-ID: <3898CE36.97E8EBF9@assigncorp.com>


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:
  2. A new DAD called test_icx.
  3. 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.
  4. Enter the DBA username and password.
  5. A new PL/SQL agent called test_icx.
  6. 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)
  7. Set up Perl Cartridge.
  8. 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
  9. For this example, check the following:
  10. hello.pl is installed in the following directory:
  11. NT: %ORACLE_HOME%\ows\3.0\sample\perl ii. UNIX: %ORACLE_HOME%/ows/3.0/sample/perl
  12. 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 "<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

  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 <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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US