The simplest method of deploying an Axis2 web service
I think Apache Axis2 is the most effective, efficient and useful open source java web service framework ever written. Not only that, if you are new to Java web services, Axis2 provides a lot of handy tools and mechanisms in order to start exploring WS technology. One of the easiest way of learning Axis2 is start with POJO (Plain old Java objects). You may wonder that you can deploy a java class as an Axis2 service in one line of code!!!
Lets have a look...
1. Write a java class
2. Add following line inside the main method of your class
new AxisServer().deployService(SimplePojo.class.getName());
Make sure to add Axis2 libraries in your class path. (Axis2-1.3 can be downloaded from here)
3. Open your favorite browser and issue http://localhost:6060
4. You will see that your java class is exposed as an web service.
Here is the complete sample code which can be copied to your IDE and play with it.
package org.test;
import org.apache.axis2.AxisFault;
import org.apache.axis2.engine.AxisServer;
public class SimplePojo {
public int addnumbers(int x, int y){
return x+y;
}
public static void main(String[] args)throws AxisFault {
new AxisServer().deployService(SimplePojo.class.getName());
}
}
Lets have a look...
1. Write a java class
2. Add following line inside the main method of your class
new AxisServer().deployService(SimplePojo.class.getName());
Make sure to add Axis2 libraries in your class path. (Axis2-1.3 can be downloaded from here)
3. Open your favorite browser and issue http://localhost:6060
4. You will see that your java class is exposed as an web service.
Here is the complete sample code which can be copied to your IDE and play with it.
package org.test;
import org.apache.axis2.AxisFault;
import org.apache.axis2.engine.AxisServer;
public class SimplePojo {
public int addnumbers(int x, int y){
return x+y;
}
public static void main(String[] args)throws AxisFault {
new AxisServer().deployService(SimplePojo.class.getName());
}
}
Comments