Web Request Broker API (Acrobat)
~47K
The Oracle Web Request Broker (WRB) provides a powerful distributed runtime environment for developing and deploying industrial strength applications for the World Wide Web. The WRB runtime platform enables application developers to write applications that are independent of and work with a number of HTTP Servers.
The Web Request Broker (WRB) API provides a programmatic interface to the Oracle Web Request Broker and enables applications developers to develop their applications (called cartridges in this document) for the WRB. The WRB API provides a higher level API that abstracts away the HTTP protocol while providing the necessary interfaces for application development. In addition, the WRB API provides a rich set of API's for authentication, logging, and attribute management to facilitate application development.
The WRB API and the runtime system together enable web applications to be run on a scalable, distributed high-performance back-end infrastructure. The following document describes the WRB API in detail.
The WRB API has been designed to address several deficiencies in the current HTTP Server programmatic interfaces and to meet the following goals:
Fig 1: Web Request Broker Architecture
The WRB Dispatcher is the component of the WRB that provides the interaction with different underlying HTTP Servers. It is responsible for routing HTTP requests to the appropriate web application cartridge over the distributed substrate. The HTTP server, in turn, interacts with the web browser using HTTP. The WRB Dispatcher looks up and locates the appropriate cartridge for a request from the WRB configuration and dispatches the request for execution to that cartridge. The WRB can run multiple instances of the web cartridge, and the Dispatcher selects an appropriate instance based on overall system load to deliver optimum application performance. The WRB Dispatcher also authenticates the request against the WRB configuration if the WRB-enabled application is using WRB Authentication Services.
Application developers develop their cartridges as shared libraries (on Solaris) and register them with the WRB Dispatcher. The cartridges are loaded in by the WRB Application Engine when a request for that cartridge is received by the WRB Dispatcher. The WRB Application Engine provides the runtime environment for WRB-enabled applications. It enables WRB-enabled applications to receive and send data to the client, as well as the ability to call other cartridges, which may be located on the same WRB or may be distributed across WRBÕs and other HTTP Servers.
The APIÕs provided by the WRB Application Engine are described below.
The WRB API provides application developers with a comprehensive set of calls to build applications independent of the underlying http daemons used. The API is organized as follows:
Cartridge developers need to provide the following WRB
Application Callbacks that the WRB Application Engine will invoke as
described below upon receiving a request from a client for a given
cartridge. The bulk of processing by the WRB cartridge is done in
the
WRBReturnCode WRB_Init( void **clientCtx );
This callback is invoked by WRB Application Engine on its initialization. The WRB cartridge initializes its context in this routine which is then made available to the cartridge on subsequent call backs.
WRBReturnCode WRB_Exec( void *WRBCtx, void *clientCtx );
This callback is invoked by WRB Application Engine upon receiving a HTTP Request. The WRB cartridge is responsible for creating the response that is written back to the Listener in this callback
WRBReturnCode WRB_Shutdown( void *WRBCtx, void *clientCtx);
The WRB Application Engine invokes this call back to provide an graceful exit for the WRB Client. Any memory allocated in the client context during the init callback should be deallocated here.
WRBReturnCode WRB_Reload(void *WRBCtx, void *clientCtx);
This callback is not required, but is recommended. The WRB Application Engine invokes this call back whenever the Web Listener has been signalled to reload its own configuration files. The Web Listener halts all new incoming connections, allows existing transactions to complete, and then signals each running WRB cartridge to execute its reload callback (if one exists). If your application uses configuration information from the OWS_APPFILE then you should call WRBGetAppConfig again, as these values may have.
char *WRB_Version();
The version callback enables the cartridge to return a character string with information about the version of that cartridge. This callback is made by the ÒÒwlctl2Ó utility
void WRB_Version_Free();
The version free callback enables the cartridge to free the memory allocated by the version callback. This callback is made by the Òwlctl2Ó utility after a successful call to the version callback.
The following Listener Information functions provide cartridge developers with information, if required, from the client as well as the underlying HTTP Server. All functions return pointers to WRB Application Engine memory which the WRB client should not modify.
char *WRBGetURL( void* WRBCtx );
char *WRBGetURI( void* WRBCtx );
Returns the URL/URI received from the HTTP Server. The cartridge developers may extract additional information from the URI/URL if required.
char *WRBGetEnvironmentVariable( void *WRBCtx, char *szEnvVar );
Returns the value of an environment variable. This provides a way for the WRB client to access CGI Environment variables. Returns NULL if szEnvVar points to a invalid environment variable.
char **WRBGetEnvironment( void *WRBCtx );
Returns the HTTP Server environment as an array of null terminated strings with the syntax varname=varvalue. Returns NULL in case of an error.
char *WRBGetContent( void *WRBCtx );
Returns either the Query String or the POST data content depending on the type of the request method. Returns NULL in case on an error.
char *WRBGetLanguage( void *WRBCtx );
Returns the WRB Application Engine Language preferences. Returns NULL in case of an error. On success, returns a comma delimited list of the ÒAcceptÓ languages.
char *WRBGetCharacterEncoding( void *WRBCtx );
Returns the WRB Application Engine Character Encoding preferences. Returns NULL in case of an error. On success, returns a comma delimited list of the ÒAcceptÓ encodings
WRBReturnCode WRBGetParsedQueryString(void *WRBCtx, WRBEntry **WRBEntries, int *numEntries); typedef struct { char *name; char *value; } WRBEntry;
Returns an array of name-value pairs after parsing the query string/POST data.
char *WRBGetNamedEntry( char *entryName, WRBEntry *WRBEntries, int numEntries);
Returns a name/value pair from a list of entries generated by a call to WRBGetParsedContent. Returns NULL on error
char *WRBGetORACLE_HOME( void *WRBCtx );
Returns the ORACLE_HOME which was set when the Web Listener was started
char **WRBGetAppConfig( void *WRBCtx );
Returns the configuration information for the current
application. The structure of the return value is a pointer to an
array of pointers to character strings. These character strings
are of the form Òname=valÓ. The information is retrieved from
the OWS_APPFILE at the time the Web Listener starts up. An
example might be: [MyCartidge]
myparam1 = val1
myparam2 = val2
char *WRBGetConfigVal( void *WRBCtx, char *name );
Returns a named item for the applicationÕs configuration. The information is retrieved from the OWS_APPFILE at the time the Web Listener starts up.
These functions are invoked by the WRB cartridge to respond to an incoming client request.
ssize_t WRBClientRead( void *WRBCtx, char *szData, int *nBytes );
The WRB Client invokes this function to read the POST data of a HTTP request from the WRB Application Engine. In the current implementation, if a client is going to read POST data it must do so bwfore sending any data (through WRBClientWrite) back to the Web Listener. The return value is the number of bytes read.
ssize_t WRBClientWrite( void *WRBCtx, char *szData, int nBytes);
The WRB cartridge invokes this function to send data to the client. The return value is the number of bytes written.
WRBReturnCode WRBClientWriteFile( void *WRBCtx, char *szFileName, WRBFileType nFileType );
The WRB client invokes this function to send the contents of a file to the client. The file can be located either in the HTTP Servers physical or virtual file system. The file type is specified in the nFileType parameter.
ssize_t WRBHTTPReturnError( void *WRBCtx, WRBErrorCode, nErrorCode, char *szErrorMesg, boolean close);
Invoked by the WRB client when it would like a standard HTTP
error sent back to the browser. This call must occur before any
other calls to WRBClientWrite, as it is a wrapper which sends :
Status
WRBReturnCode WRBCallCartridge( void *WRBCtx, char *request);
The WRB client calls this function to invoke a request which could be satisfied by a cartridge running on the local WRB, or by a remote HTTP Server or WRB.
WRBReturnCode WRBClientSetTimeOut( void *WRBCtx, int nTimeOut, WRBReturnCode (*WRBClientCleanUP)( *void WRBCtx ) );
This function can be called by the WRB client to set a time out for long running calls. If WRB Client makes this call the WRB Application Engine sets up a timer to interrupt processing a HTTP request and return to the LIstener with a timedout error response. The WRB client can set a callback WRBClientCleanUp to clean up the client in case of a timeout. WRB Application Engine discards any response from the WRB client once the timeout has happened. If no callback is provided a default callback is used.
ssize_t WRBReturnHTTPRedirect( void *WRBCtx, char *szURI, boolean close);
Invoked by the WRB client when it would like a standard HTTP
error sent back to the browser. This call must come before any
other calls to WRBClientWrite, as it is just a wrapper which
sends : Status:
ssize_t WRBCloseHTTPHeaer( void *WRBCtx ); Invoked by the WRB client when it would like to close an HTTP header. Generally used after calls to WRBReturnHTTPError or WRBReturnHTTPRedirect with the ÒcloseÓ flag set to FALSE.
void WRBLogMessage( void *WRBCtx, char *szMessage, int nSeverity );
Logs the message szMessage to a file ?/ows2/log/wrb_
The following section describes a simple example of Web Application written using the WRB API functions. This application prints hello world in the browser window
#ifndef ORATYPES_ORACLE # include <oratypes.h> #endif #ifndef WRB_ORACLE # include <wrb.h> #endif WRBReturnCode test_init(); WRBReturnCode test_exec(); WRBReturnCode test_shut(); /*******************************************************************/ /* Client-provided callback functions */ /*******************************************************************/ /* The following function defintions should be provided by theWRBclient /* such that the WRB can invoke the users application.The WRB client */ /* must have a single entry point, which gets specified in the [Apps] */ /* section of the WRB configuration file. */ /* */ /* This entry point function should fill in the WRBCallbacks table that /* it is passed, such that the WRB can call the init, exec, and shut /* routines respectively (explained below). */ /* */ /* A simple example of a valid entry function would be: */ /* WRBReturnCode mydyn_init(WRBCallbacks *WRBcalls) /* { */ /* WRBcalls->init_WRBCallback = my_init; */ /* WRBcalls->exec_WRBCallback = my_exec; */ /* WRBcalls->shut_WRBCallback = my_shut; */ /* */ /* return WRB_DONE */ /* } */ WRBReturnCode testentry (WRBCalls) WRBCallbacks *WRBCalls; { WRBCalls->init_WRBCallback = test_init; WRBCalls->exec_WRBCallback = test_exec; WRBCalls->shut_WRBCallback = test_shut; return (WRB_DONE); } WRBReturnCode test_init( WRBCtx, clientcxp ) void *WRBCtx; void **clientcxp; { return (WRB_DONE); } WRBReturnCode test_exec( WRBCtx, clientcxp ) void *WRBCtx; void *clientcxp; { WRBClientWrite(WRBCtx, ÒContent-type: text/html\n\n HelloWorld\nÓ, 40); return (WRB_DONE); } WRBReturnCode test_shut( WRBCtx, clientcxp ) void *WRBCtx; void *clientcxp; { return (WRB_DONE); }
This section describes the makefile for building Web Request Broker cartridges.
#Makefile for building WRB Cartridges #==================================== LIBHOME = $(ORACLE_HOME)/ows2/wrbsdk/lib INCHOME = $(ORACLE_HOME)/ows2/wrbsdk/inc LDCOM = -g -xs -L$(LIBHOME) SLIBS = -lnsl -lm -lsocket -ldl -laio all: helloworld.so helloworld.o:helloworld.c $(CC)-c -o $@ -g -I$(INCHOME) helloworld.c #The link line for the final .so dynamic library is given below helloworld.so: helloworld.o $(CC) $(LDCOM) -o $@ -G helloworld.o $(SLIBS)
All new cartridges will need to register themselves in the WRB config file which is read by the server at startup. The config file has the same name as the listener configuration file but has an extension .app
In the WRB config file the following sections will need to be filled.
[Apps] ; ; APP Object Path Entry Point Min Max ; === =========== =========== === === OWA /private/oracle/ows2/lib/libndwoa.so ndwoadinit 0 100 SSI /vobs/ws/src/ssi/ndwussi.so ndwussinit 0 100 JAVA /private/oracle/ows2/lib/libjava.so ojsdinit 0 100
[AppDirs] ; ; Virtual Path APP Physical Path ; ============ === ============= /ssi SSI /private/oracle/ows2/sample/ssi /hr/owa OWA /private/oracle/ows2/bin /tr/owa OWA /private/oracle/ows2/bin /owa_dba/owa OWA /private/oracle/ows2/bin /java JAVA /private/oracle/ows2/java
/owa_dba/owa/* Basic(Admin Server) /hr/owa Basic(registered) | IP(oracle)
Each cartrdige can specfify its own configuration information which is availabe to it thru the WRB_GetAppConfig call. The configuration information should be in the format A = B.
[SSI] EnableLiveHTML = TRUE ParseHTMLExtn = FALSE EnableExecTag = TRUE ExtensionList = html shtml lhtml MaxRequests = 1
Table 1: References
SpyGlass Server ADI | Spyglass Server Reference Manual Version 1.1. http://www.spyglass.com:4040/support | Internet Server API | A specification for Writing Internet Server Applications. http://www.microsoft.com/intdev/inttech/isapi.htm | Netscape Server API | The Netscape Server API. http://home.netscape.com | Open Market FastCGI | FastCGI Specification. http://www.openmarket.com/fcgi-spec.html |
Copyright © 1996 Oracle Corporation. All Rights Reserved.