Friday, March 27, 2009

A simple webservice with Apache Axis

Hi readers,
    There're many ways to depvelop a webservice. In this post, I want to introduce a way to build webservice with apache axis ( I'm going to implement a very simple function: when receiving a request from client, server will reponse a string to client.
What should we need?
    IDE: Eclipse 3.4.
    Library: apache axis.
1, Create a dynamic web project inside eclipse.
2, Add the librarise (as listed above) into the project, also add these to build path.
3, Write your codes.
4, Export war file (using eclipse or ant task).
5, Put war file into apache tomcat server (webapps directory)
6, Open browser and test (eg: http://localhost:8080/ws-simple/services/EchoService?wsdl)

The picture below is the structure of application.

Let look inside the application: is a complex parameter of webservice. is an interface in which there're three functions:
        public String echo(String message);
        public String addUser(User user) throws Exception;
        public String printback(String text); implemented class of the above interface.
+Declare Axis servlet in web.xml file.
+Expose the webservice by using server-config.wsdd file.
    -To create server-config.wsdd file we can use Java2WSDL tool inside apache axis library.

No comments:

Post a Comment