mod_wscpp is an Apache module, part of a Web Services C++ Framework, that allows to serve SOAP requests via the gSOAP library, with session information and Web Services implemented in multiple libraries.

Some features in mod_wscpp could be used as reference for developers, for example:

  • building of multiple gSOAP client/server libraries
  • development of gSOAP plugin
  • Apache module in C++
  • Apache module with shared memory
  • Apache module compiling with MinGW
  • Apache module with session information

Compilation

Build folder includes Code::Blocks project files for Windows (MinGW) and Linux. There are Makefiles for Linux and Windows (makefile.gcc for MinGW), so on Linux the traditional make command works and on Windows the command is

mingw32-make -f makefile.gcc

Also, to remove the generated files, use make clean

APXS and C implementation

It would be posible to use apxs to generate the Apache module if we rename the file wscpp_soap.cpp to wscpp_soap.c. The web services need to be implemented in C and the apxs command would be:

apxs -Iinclude/ -I../gsoap-2.7/gsoap/ -i -c src/mod_wscpp.c src/mod_wscpp_util.c src/wscpp_soap.c

When using the soapcpp2 application, remember to set the parameters to work with C code (see gSOAP documentation).

Configuration

Apache needs a configuration like in the file samples/mod_wscpp.conf (remember the file name extensions for libraries, .dll in Windows and .so in Linux):
LoadModule wscpp_module modules/mod_wscpp.dll

<IfModule mod_wscpp.c>
<Location /wscpp>
    SetHandler wscpp-handler
    wscppWorkingPath wscpp/
</Location>
</IfModule>

Inside the Apache home directory, the module will search for a directory tree like the following (like in samples/minimal/wscpp/)

wscpp
|-- wscpp.xml 
|-- stdsoap2.dll
|-- webservice1
|   |-- library1.dll
|   `-- wscpp.xml
|-- webservice2
|   |-- library2.dll
|   `-- wscpp.xml
...

The parameters set in the general wscpp.xml (the one in the wscpp/ directory) are:

gsoap-librarythe location of the libstdsoap2 library
load-libraryaditional libraries to load
wscpp-parampairs of parameter-value definitions reachable by the web services
<?xml version="1.0" encoding="ISO-8859-1"?>
<wscpp-module>
  <gsoap-library>wscpp/stdsoap2.dll</gsoap-library>
  <load-library>wscpp/additionallib.dll</load-library>
  <wscpp-param>
    <param id="myparameter">myvalue</param>
    <param id="mystrcon">host='%s' dbname='%d' user='%u' password='%p'</param>
  </wscpp-param>
</wscpp-module>

The parameters set in every sub wscpp.xml (the ones in the subdirectories of wscpp/) are:

library-filethe name of the library implementing the web services
virtual-locationthe virtual subdirectory for the execution of the web services
<?xml version="1.0" encoding="ISO-8859-1"?>
<wscpp-module>
  <library-file>library1.dll</library-file>
  <virtual-location>subdirectory1</virtual-location>
</wscpp-module>