Initialization in C
The initialization function must have the following prototype:
myfunc(pblock *pb, Session *sn, Request *rq)
In the initialization function, you create a new web application service and register the service. As is the case with standalone applications, you call the WAIcreateWebAppService()
function to create the service and WAIregisterService()
to register the service. For example:
...
// Declare the global variable obj as the web service
IIOPWebAppService_t obj;
...
// Create a new web application service
obj = WAIcreateWebAppService("MyServiceName", MyRunFunction, 0, 0);
// Register the web application service
WAIregisterService(obj, "");
...
Unlike standalone applications, you do not need to specify host and port information as arguments to the WAIcreateWebAppService()
function. Because your service runs within the web server process, the host and port information is not necessary.
The following example registers a web application service under the instance name CIIOPip
. The service is defined in a server plug-in, which provides the initialization function CIIOPinit()
for registering the service.
...
// Define your Run function
long
MyRunFunction(ServerSession_t obj)
{
...
}
...
// Declare the global variable anObject as a web service instance
IIOPWebAppService_t obj;
...
// Specify the right type for compiling on Windows NT
#if defined(WIN32)
#define DLLEXPORT __declspec(dllexport)
#else
#define DLLEXPORT
#endif
...
// Make the initialization function available
extern "C" {
DLLEXPORT int CIIOPinit(pblock *pb, Session *sn, Request *rq);
}
...
// Your initialization function (called at server startup)
int
CIIOPinit(pblock *pb, Session *sn, Request *rq)
{
// Create a new web application service
obj = WAIcreateWebAppService("CIIOPip", MyRunFunction, 0, 0);
// Register the web application service
WAIregisterService(obj, "");
return 0;
}
...
Configuring Your Web Server
Next, you need to configure the web server to run your initialization function when the server starts up.
Add the following Init
directives to your obj.conf
file (which is located under server_root
/
server_id
/config
in UNIX and server_root
\
server_id
\config
in Windows NT.
Init funcs="init_function" fn="load-modules" shlib="shared_lib"
Init fn="init_function"
For example, suppose you define an initialization function myinit()
in a shared/dynamic library /usr/netscape/suitespot/wai/lib/mylib.so
. You need to add the following directives to your obj.conf
file:
Init funcs="myinit" fn="load-modules" shlib="/usr/netscape/suitespot/wai/lib/mylib.so"
Init fn="myinit"
When a WAI plugin needs to be run in-process to the http server, the load-modules and Init
directives for this should occur after those corresponding to the load-modules and Init
directives libONEiiop.so
(or .dll
).
Last Updated: 12/04/97 16:12:42
Any sample code included above is provided for your use on an "AS IS" basis, under the Netscape License Agreement - Terms of Use