Apache Server SOAP module for IdooXoap

This is an open source contribution by Christian Aberger for IdooXoap, an open source SOAP implementation that enables Apache Server to be a SOAP server.

Overview

The IdooXoap SOAP service consists of two main parts:

  1. mod_isoap, which is a SOAP server independent generic module to allow IdooXoap servers to be plugged into Apache Server. It contains the infrastructure to dynamically load the required IdooXoap servers at runtime, and the support libraries they need. It reads the SOAP requests from the clients, calls into the SOAP server shared libraries and returns the response to the clients.

  2. One or more IdooXoap server shared libraries that implement the SOAP services. As a sample the structures sample from the IdooXoap distribution was used. Implementing other SOAP servers is straight forward. Please see IdooXoap for details of how to use ServiceCompilerC to generate the C++ code for other servers.

The build process also reflects this separation into 2 pieces. The mod_isoap is built in the standard Apache way, while the SOAP servers use Automake in order to be portable. Please do not be shocked about the long description that follows. What follows is a very detailled description, also for users not very much acquainted with apache server.

Building the Apache SOAP server

In order to reduce download times you have to download and unpack standard packages like xerces and apache server separately from their original locations. The following description assumes that you unpack the apache source directly into your home directory, which will be abbreviated with ~. Any other directory will also be OK, but it is important that you keep the relative location of the directories below apache intact. For building I used libtool 1.4 downloaded from http://www.gnu.org/software/libtool, be sure to install it with ./configure then make and make install. I am afraid you will not be able to compile it with older versions of libtool.

Download and Unpack

Build

The build consists of two main parts: building the SOAP server shared libaries that implement your personal SOAP servers, independent of Apache server. The second step is to build mod_isoap, which is an apache module that will load any of your SOAP servers into Apache server and execute it if requests for it come in.

Build the SOAP server shared libraries

In a command shell change to the directory ~/apache/src/modules/isoap/SOAP. Then run:

./configure
make

This will build the libraries and shared objects required.

Note: If you build for a production environment, you should remove the debugging code. You can set other compiler options in the configure.in file. Search for the line containing [CXXFLAGS="-g -D_NDEBUG"], then run automake, autoconf, configure, make clean, make.

Implementing your own Servers

There is also a ConsoleServer subproject, that allows you to build and test your own IdooXoap servers indepent of Apache server. It is recommended to test your servers with this soaptest program before you try to use it in Apache Server. Change the search path for the library and the name of the library near the top of the file ConsoleServer.cpp for testing. Another subdirectory „foo“ is there for testing, if you still get „file not found“ errors in the attempt to load a shared library. „foo“ does not depend on other libraries and will load also if your LD_LIBRARY_PATH is not correct. Of course it will not work as a soap server, it is only there to get your directory settings correct.

If you want to have a graphical development environment you can use kdevelop. See below how to use that. But also working with emacs and kdbg is fine. For implementing your own SOAP servers please download the standard package IdooXoap and follow the instructions there. The servers we use are separated into a shared library of its own, to allow the apache server to load them on demand.

Adjust Serverfactory.cpp for your own server

The only additional thing you must do to run your IdooXoap Server under Apache server is to add the file ServerFactory.cpp to your project and change the name of the include file and the name of your server. Here is the file as it is used for the structures sample:

#define DYNAMIC_SOAP_SERVER_IMPLEMENTATION
#include "DynamicSOAPServer.h"
#include "serviceIA.h" // just as a demo. Add here whatever include files you need for your IdooXoap SOAP server.

BEGIN_SOAP_SERVER_ENTRY_TABLE
    SOAP_SERVER_ENTRY("structures", serviceIA)
END_SOAP_SERVER_ENTRY_TABLE

Rename everywhere „structures“ with the name of your server. If you use additional files to implement your server, you have to add these to Makefile.am and rename structures to whatever name your SOAP server has. After that run automake, autoconf, configure, make clean, make from the~/apache/src/modules/isoap/SOAP directory.

Set the LD_LIBRARY_PATH

For testing the Soap servers with ConsoleServer.cpp your need the libxerces-c1_4.so shared library. Make sure that your LD_LIBRARY_PATH contains this. For example, add to your ~/.bashrc file the following line:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/apache/src/modules/isoap/SOAP/xerces/lib

or copy the libxerces-c1_4.so to an appropriate place in your LD_LIBRARY_PATH

Note: Due to security reasons the loader in mod_isoap does not use the LD_LIBRARY_PATH, you have to explicitly configure the location of your SOAP server shared libraries in the file httpd.conf (see later for mod_isoap).

Build the Apache Server Module mod_isoap

mod_isoap is responible to call your SOAP server dynamic library when a SOAPAction request comes in. It is independent of your SOAP servers and a general interface to Apache Server. It is built in the standard way as Apache Server 3rd party libraries are built. Follow the following steps:

Programming and Debugging Tips

Lookup the error log file of Apache Server

mod_isoap logs apache errors in the standard way. So see the apache log file, typically it is located at /usr/local/apache/logs/apache_log.

Compile with symbolic information

For debugging it is necessary to compile with the -g compiler option. There are two places where you must adjust this. In the ~/apache/src/Configuration file search for the line where EXTRA_CFLAGS is and add a -g to it:
EXTRA_CFLAGS=-g
In the file ~/apache/src/modules/isoap/SOAP/configure.in you should remove the dnl from the line that sets the CXXFLAGS if there is any, so that it reads:
[CXXFLAGS="-g -D_NDEBUG"]
Then run:
automake
autoconf
configure
make clean
make
in that directory. Make clean in the ~/apache and in the ~/apache/src/modules/isoap/SOAP directories and rebuild all. Don't forget to remove these settings for the release build again.

Be sure you Debug the correct process

Sometimes when you exit the debugger it can happen that the httpd process is still alive. So before you continue, it might be a good idea to run
ps -ef | grep httpd
to see if there is still a server alive, which should be killed before the next debugging session. For killing all active httpd processes I use:
kill `ps -ef | grep httpd | sed -e"s/\ * /:/g" | cut -f2 -d:`

You do not debug the process /usr/local/apache/bin/httpd, but the httpd program that you build in your source code directory ~/apache/src. The key to successful debugging is the -X flag. So in your debugger run httpd from ~/apache/src, but use the same configuration file as your production server will use. Use the following commandline to start debugging:
./httpd -X -f /usr/local/apache/conf/httpd.conf

When the process is started in the debugger, set your breakpoints and use your favourite browser and refresh the page http://127.0.0.1:8080/soap.

How to use kdevelop for Programming and Debugging of Apache modules

If you want to use kdevelop to debug Apache then you can change to the directory ~/apache/src and run:
kimport > apache.kdevprj

After that you can open apache.kdevprj as a kdevelop project. A SOAP.kdevprj is included in the source, you can generate it in a similar way if you have a newer version of kdevelop. Use the appropriate dialogs in your debugging environment to set the commandline arguments for debugging.


I hope you will have fun with this.

Enjoy,

Christian Aberger.