Tuesday, February 16, 2010

Develop Web Services with Axis2 - System Setup

Axis2 is a very cool application platform for web service development. I'm doing a small project about how to develop a distributed raytracing web service based on Axis2. The advantages of Axis2 is obvious: Speed, Flexibility, Stability, Component-oriented Deployment, Transport Framework, and WSDL Support. But it has disadvantage; it is difficult to set up and implement.

Before we start, there are some basic concepts that you need to know.

1. Web service

In a web service, two kinds of entities are involved: the server and the client. They communicate with each other by some predefined protocol, e.g. http. The server provides some APIs for the clients, and the client then make use of these APIs to do its own job.

2. SOAP (Simple Object Access Protocol)

SOAP is a XML-based procotol specification used for exchanging messages between different applications (from different machines). SOAP is usually based on http, or other application layer protocols. It's the foundation layer of web service stack.

3. WSDL (Web Service Description Language)

WSDL is a XML-based language for describing web serivces. The WSDL defines services as collections of network endpoints, or ports. A port is defined by associating a network address with a reusable binding, and a collection of ports defines a service. Messages are abstract descriptions of the data being exchanged, and port types are abstract collections of supported operations.

Now it's time to start! To have an overall understanding of Axis2, please refer to official Apache Axis2 website here. The following content will tell you how to set up your Axis2 environment. I'm using intel machine with Win Vista system.

1. Install neccessary software


Install Apache Tomcat server. I'm using Tomcat6, but 5.5 would also be fine. You can find it here. Make sure you have correctly installed your JAVA JDK. Then you need to download Axis2 from Apache official website. I used Axis2 1.5 here. Also, you need to install Apache Ant.





2. Set up environment variables


After installation, you need to set up ANT_HOME environment variable in your system settings. The value of this variable should be the installation path of ant on your machine. Then edit the "path" variable, add ";%ANT_HOME%\bin" to the end. Do this for your JAVA JRE and Axis2. The corresponding environment variables should be JAVA_HOME and AXIS2_HOME.





3. Deploy your Axis2 service


After you have installed your Axis2. Go to "webapp" folder under your Axis2 directory; you can see a build.xml file, and then switch into this path in your DOS console. Since you have already set up the environment variable for ANT, you just run the command "ant" under this folder. This will launch "ant build" with the build.xml file. After build successfully, you can find a new folder "dist" under Axis2 directory, which contains a axis2.war file. Now copy this file into the "webapps" folder under your Tomcat directory. (Re)start Tomcat by running startup.bat under the "bin" folder. This will automatically deploy your Axis2 service. If this is done successfully, you would be able to see a new Axis2 folder within the "webapps" folder. In addition, you can open your explorer and go to http://localhost:8080/ (8080 is the default port number of Tomcat, you can always alter it in the configuration file). If this page is successfully loaded, your Tomcat is installed correctly. Then goto http://localhost:8080/axis2 which is the admin page of your Axis2 services. You can view your current services, change access information, ect.




OK! You have done really well! BUT remember this is just a beginning. There would be a lot of work to do later. Take a breath and we'll come back soon!

No comments: