Thursday, November 1, 2012

Write your first Axis2 service


In this post I will describe on how to create a simple HelloWorld axis2 service by following three simple steps.
  1. Implement the service class
  2. Create the services.xml file
  3. Pack the service as .aar file archive
Implement the service class
    First we need to create the service class and the service methods. We will create HelloService.java service class and sayHello operation as shown below.


Create the services.xml file

    services.xml is a configuration file which all the axis2 web services must have.
    Create a META-INF directory and create the services.xml file inside the META-INF directory.
    You should define the service class as a parameter in services.xml

                 Your project structure will look like the following.



Pack the service as .aar file archive

    Compile your service class using javac command.
                  ie: javac HelloService.java -d ./ 
    
    Get a copy of your META-INF directory and the compiled .class file of the service to a temp
    directory. Now the tree structure of those should be as follows.


    Create an archive file with the META-INF directory and the compiled .class file of the service
    class and rename the archive to a .aar   
    
    Now you have a deployable axis2 service with you.












No comments:

Post a Comment