Submitted on August 26, 2008 - 03:13.
In this tutorial, Supun Kamburugamuva illustrates debugging Apache Axis2/C services and clients in both Windows and Linux platforms under different deployment scenarios.
| Project/Lan | Apache Axis2/C any version |
| Tools Required | gdb, Visual Studio 2005 |
| Environment | Linux or Windows |
As an Apache Axis2/C Web services developer, at one point or the other during the development cycle the need will arise for you to debug Axis2/C services and clients.
I assume you have a basic knowledge on debugging programs in Linux or Windows. You will also need to have a source distribution of Axis2/C available as I will be using a sample service and a client shipped with Axis2/C for llustrating the debugging procedure. If you have a source distribution, you can build it by following the guidelines given in the Axis2/C manual and installation guide. Building Axis2/C on any supported platform is a very easy task.
I have used an echo service and a client for demonstrating the debugging procedure. Source code for the client and server can be found in <AXIS2C_SRC_DIR>/sample/clients/echo and <AXIS2C_SRC_DIR>/sample/server/echo locations, respectively.
If you do not want to build Axis2/C from the scratch, you can use your own service and client with a binary distribution of Axis2/C. Obviously, both the service and client must be built with debugging enabled.
Axis2/C Web services are shared object files (in Linux) or dynamic link library files (in Windows) that exports two functions and instantiate the axis2_svc_skeleton_t structure. Services are deployed in the <AXIS2C_BIN_HOME>/services directory. A service has a .so (Linux) or .dll (Windows) file and a configuration file called services.xml. Services should be hosted within a folder with the name as the service.
You need to build Axis2/C and its samples as specified in the Axis2/C manual. Client binaries are copied into the directory {AXIS2C_BIN_DIR}/bin/samples. Services binaries are copied into the {AXIS2C_BIN_DIR}/services directory.
If you are using your own service deploy it to Axis2/C.
Start Axis2/C and type the http://<yourserver>/axis2/services in your Web browser to verify whether the service is actually deployed or not. If the service is deployed correctly, your service name should be in the list of services that are displayed in the browser.
Note: Axis2/C Windows source distribution has a Visual Studio 2005 solution. The solution can be found in <AXIS2C_SRC_DIR>/ides/vc/axis2c directory.
Axis2 HTTP server is a simple HTTP server capable of hosting Axis2/C Web services only. It is part of the Axis2/C distribution. Axis2 HTTP server binary can be found in the <AXIS2C_BIN_HOME>/bin directory.
Starting the axis2_http_server from the Axis2/C VC solution
Obviously the first thing you need to do is to start the axis2_http_server. If you start the axis2_http_server from the Axis2/C VC solution, you can then go ahead and directly start debugging the services. All you have to do is to put a few break points in to the service files within the Axis2/C solution. Following are the steps required:
Starting the axis2_http_server from command prompt
If you didn’t start axis2_http_server from the Axis2/C VC solution, then you need to use the service's VC solution or Axis2/C solution for debugging the service. If you are using a binary version of Axis2/C, then the only option you have is the service’s VC solution.
If the service is properly loaded by Axis2/C, you must be able to debug the service. Axis2/C loads the services when it receives the first request for that service. So when you specify debug points for a service without sending a request to that service, breakpoints appear as yellow circles ( and not red circles). This indicates that no symbols are loaded for the break points. This is perfectly normal since Axis2/C does not load a service until the first request for that service is received.
$ gdb axis2_http_server (gdb) br <break points> (gdb) r
In the figure above I have shown a debug session of the echo sample service.
The above process is similar in Axis2/c tcp server as well.
Follow instructions given in the Axis2/C manual to install Axis2/C with the Apache server.
$ gdb httpd (gdb) br <break point> (gdb) run -X
You may want to run the gdb command as super user. When you try to set break points, gdb will complain saying that it cannot find break points. Then it will ask you to make the break points pending similar to the case with the axis2 http server. Specify yes to and run the server.
If everything goes well, the break points should hit. The figure below illustrates a debugging session for Axis2/C with httpd.
With IIS server, the process is almost same as with the Apache server. Deploy Axis2/C in the IIS, by following guidelines given in the Axis2/C manual. Then start the IIS server. If you are using IIS 6 or 7, you first need to send a request to the IIS server before start debugging. In IIS 6 and 7, Axis2/C is initialized when IIS receives the first request for Axis2/C.
Axis2/C clients are executable files. So you can start debugging clients rightaway, as you would do with any other executable. In Linux, start the client using gdb. For Windows, start debugging the client from its VC project.
In this tutorial I’ve focused on illustrating how to debug Axis2/C services in different deployment scenarios. If you follow the tutorial carefully, you will clearly see that it is very easy to setup and debug Axis2/C services.
Supun Kamburugamuva, Software Engineer, WSO2.Inc, supun AT wso2 DOT com