How to Debug Your Axis2 Web Service in 3 Steps Using Eclipse?

In this short "how to" tutorial, Saminda Wijeratne, Senior Software Engineer at WSO2, guides you in debugging your Web service using WSO2 Web Services Application Server (WSO2 WSAS) Tools and the eclipse IDE. This tutorial helps you to easily debug your Web service using  eclipse IDE. Regardless whether you are a developer or an admin or a simple user you will find this tutorial simple enough to understand in order to debug any Web service you want to find issues.

Date: Mon, 9th Nov, 2009
Level: Introductory
Reads: 8369 Comments: 0 | Login or register to post comments
Saminda Wijeratne
Senior Software Engineer
WSO2 Inc
samindaw's picture

Web services have become mainstream and many create and consume Web services for their day to day operations. Every piece of Web service we write today is not 100% perfect and has few bugs. When an issue occurs in the web service it takes tremendous amount of time to go through the code and resolve if you don't have the perfect tools to do it.

The 3 steps are

  1. Setting up the environment
  2. Set breakpoints in the code
  3. Start the server in debug mode

The first step is to just create a Web service so that we can debug it later.

Prerequisites

Eclipse

3.4 or higher
Java 1.5 or higher
WSO2 Web Services Application Server (WSO2 WSAS) 3.1.x
Eclipse Features

WSO2 Web Services Authoring & Testing Tools - v1.1.0

WSO2 Web Services Application Server (WSO2 WSAS) v3.1 - v1.0.0

 

 

 

 

 

 


Note: Visit the resources section of this tutorial to find out from where to download the prerequisites or click the above links.

 

You may also download the resources for this tutorial from the resources section.

If you have done this tutorial on creating Web services you can use the same workspace and can skip step 1.

Step 1 - Setting up the environment

Create a Web service using the following instructions

  1. Create a Dynamic web project having the WSO2 Web Services Application Server (WSO2 WSAS) facets enabled.
  2. Add a Java class which you want to expose and debug as a Web service
  3. Publish it as a Web service

(Try this tutorial on more instructions on how to follow above instructions.)

Step 2 - Set debug breakpoints

Put some debug breakpoints in the source code in places which you want the debugging to hit.

 

Step 3 - Start WSO2 Web Services Application Server (WSO2 WSAS) in "Debug Mode"

While you are in the "Java EE" perspective click on the "Servers" view. Select WSO2 Web Services Application Server (WSO2 WSAS) which your service is published in. Click "Start the server in debug mode" button in the "Server" view.

 

 

That's it. So basically all you have to do now is to invoke your service (We can use the "Try it" feature in WSO2 Web Services Application Server (WSO2 WSAS) to invoke the Web service) and see how eclipse brings up the debugging perspective with your favourite debugging tools.

Eg:

Lets invoke our Web service and see. I'm going to use the "Try it" feature in WSO2 Web Services Application Server (WSO2 WSAS) to invoke our web service


You might notice that your eclipse editor will flash in task bar and when focus will notice that it will either ask you to switch to debugging perspective (if so click "Yes") or already in debugging perspective.

 

Lets step over to the next line and change the value of the variable area to something else (say "100").

 

and click the "Resume" button in the "Debug" view to continue the execution. Check out the result in the "Try it" page which we invoked the Web service in the first palce.

 

Resources

  1. To download WSO2 Web Services Application Server (WSO2 WSAS) please visit http://wso2.org/projects/wsas/java
  2. To download WSO2 Web Services Application Server (WSO2 WSAS) Tools please visit http://wso2.org/projects/tools/ or use the update site URL http://tools.wso2.org/eclipse

Summary

With the use of WSO2 Web Services Application Server (WSO2 WSAS) Tools you can easily debug your Web service just like debugging your Java application in eclipse.

Author

Saminda Wijeratne, Senior Software Engineer, WSO2, samindaw@wso2.com