iWave Japan      Welcome to iWave Systems

ISAPI usage in WinCE webserver applications

Web Server is one which can be either Hardware such as Computer or Software, such as computer application that helps in delivering web contents that can be accessed through the Internet.

While implementing the Web server on WinCE one can’t implement all the features available with the web servers on PC Platform. WinCE Internet Information Services (IIS) does not support Maintaining Session ID. However, this particular feature can be implemented by using Internet Server Application Programming Interface (ISAPI). WinCE IIS does not support states between transaction and Session ID management, which can be supported by ISAPI application programming interface.

To do this, one has to build the Dynamic Link Library (dll) that exports some standard ISAPI entry point such as GetExtensionVersion, HttpExtensionProc and TerminateExtension. Interaction with the Web server can be performed through the standard ISAPI callback functions like ReadClient, WriteClient, etc. The following functions which can be implemented using this dlls:

  • Session ID Management
  • Providing Login Authority
  • Sending Customized files
  • Real time variables such as CPU temperature, CPU usage, Fan speed, connected devices

The following diagram shows, how the webserver interacts with ISAPI dlls.

 

How to load ISAPI Extension dll

In addition to the web server component in the build, the following registry entry should be added to load the dll automatically:

HKEY_LOCAL_MACHINE\COMM\HTTPD\VROOTS\/]

@=”\\windows\\sampleisapi.dll”

"a"=dword: 0 ;to remove the authentication

Web server loads this dll, when it receives the first request from any of its clients. And this dll is loaded only once and can handle the requests from any number of clients.

Functions to be exported

The following functions will be exported in the process of ISAPI application programming interface

1. GetExtensionVersion

This function is called when the Dll is loaded for the first time.

2. HttpExtensionProc

This function is called for every request from the client. GetServerVariable function can be used to get the Query String value. According to the query string received, the corresponding file that has been requested is written back to the client using the WriteClient function. To read the data from the client, ReadClient function is called.

3. TerminateExtension

This function is called when the driver is unloaded.

4. GetServerVariable

This function is used to get the server variables like IP address, Query string etc. This function has the ptototypes & Parameters as given below;

Prototype:

BOOL WINAPI GetServerVariable(HCONN hConn, LPSTR lpszVariableName, VOID lpvBuffer, LPDWORD lpdwSizeofBuffer );

Parameter: hConn

Specifies the connection handle. This is the input of HttpExtensionProc function.

Parameter: lpszVariableName

A null-terminated string that indicates which server variable is requested.

Parameter: lpvBuffer

Points to the buffer to receive the requested information.

Parameter: lpdwSizeofBuffer

Points to a DWORD that indicates the size of the buffer pointed to by lpvBuffer. On successful completion, the DWORD contains the size of bytes transferred into the buffer, including the null-terminating byte.

Some of the important variables that can be retrieved using GetServerVariable function are as follows.

  • PATH_INFO – The Path info given in the trailing part of the URL, as given by the client
  • QUERY_STRING – Specifies the information that follows the first question mark in the URL
  • REMOTE_ADDR – Specifies the IP address of the Client

Example of simple ISAPI implementation: 

  1. Connect WinCE device to Ethernet
  2. Client can be any browser connected to same network as WinCE device connected
  3. Get WinCE device IP address and type URL on browser say "IP addresss:port/filename" - http://192.168.2.10:8000/login.html
  4. Make sure login.html present in WinCE device
  5. Request comes from the browser to WinCE device where webserver is running
  6. Web server accepts the request and calls HttpExtensionProc function.
  7. GetServerVariable function is for getting the query string from URL. In our example it is login.html.
  8. HttpExtensionProc function will handle the request; it calls the appropriate request handler and sends the requested file (in our example login.html) as a response to the client using WriteCLient call.
  9. Once above is done, login.html will be displayed in browser.

From this article one can understand that, ISAPI extension dll can be more often used when the real time variables like CPU temperature, IP address settings are used in web based files.

Seetharama Nayak - Software Engineer
iWave Systems Technologies Pvt. Ltd.