Straight to the point: Simple Axis2 Hello World WebService
It’s the simplest possible Web Service (that I’m aware of) you can make. I will not explain the details, only the steps.
- Download AXIS2, unzip, and start it by executing: bin/axis2server.sh;
- Create the following folder structure “helloservice/META-INF”;
- Create the file “helloservice/HelloService.java” and place inside the folling code:public class HelloService
{
public String sayHello(){
return “Hello World!!!”;
}
} - Compile the class by calling “javac HelloService.java”;
- Create the file “helloservice/META-INF/services.xml” and place inside the folling code:
<service>
<parameter name=”ServiceClass” locked=”false”>HelloService</parameter>
<operation name=”sayHello”>
<messageReceiver class=”org.apache.axis2.rpc.receivers.RPCMessageReceiver”/>
</operation>
</service> - Move/copy the folder “helloservice” to inside the Axis2 folder “[AXIS_HOME]/repository/services”;
- Axis2 will deploy it giving the message “Deploying Web service: helloservice”
- Try it by requesting the url: http://localhost:8080/axis2/services/helloservice?wsdl or just http://localhost:8080/axis2/services/helloservice;