Thursday, March 17, 2011

Axis2 Webservice Hello World Tutorial

For this simple Hello World tutorial, you don’t have to install Tomcat and IDE. You can just use DOS command in Windows.

1. Install JDK 6(SE 6) from
2. Download Ant from and install it
3. Download Axis2 from
4. Unzip Axis2 into your C:\tools\axis2-154\axis2-1.5.4\
5. Create folder c:\helloworld
6. Create folder c:\helloworld\client
7. Create folder c:\helloworld\client\code
8. Create folder c:\helloworld\server
9. Create folder c:\helloword\server\META-INF
10. Now, create server java file – and save it in c:\helloworld\server
public class SayHello {
// This is service.
public String sayHello(String name) {
return "Hello " + name;
11. Compile it:

12. Create services.xml file:
<parameter name="ServiceClass"
<operation name="sayHello">
<messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>

13. Save services.xml into c:\helloword\cleint\META-INF
14. Create sayhello.aar file:

15. Go to to create a Free Trial account.
16. Use FTP upload your sayhello.aar file into /webapps/axis2/WEB-INF/services (For ftp settings, login to your EATJ account and click on Settings)
17. Go to and login to your account and click on RESTART link.
18. After restarting, you will see a URL: . Your Axis2 URL will be
19. Click on Services link. You should see your service: sayhello
20. Click on sayhello. You should see WSLD. URL is
21. So far, you created your first web service.
22. Now, we create client code to access this sayhello service.
23. Create client stub. Type: C:\tools\axis2-154\axis2-1.5.4\bin\wSDL2Java.bat -uri -o code/

24. Create client code – and save it into C:\helloworld\client\code\src\org\apache\ws\axis2


public class SayHelloClient {
public static void main(String[] args) throws Exception {
SayhelloStub stub = new SayhelloStub();

//Create the request
SayhelloStub.SayHello request = new SayhelloStub.SayHello();

//Invoke the service
SayHelloResponse response = stub.sayHello(request);
System.out.println("Response : " + response.get_return());
25. Go to C:\helloworld\client\code and type: ant
26. Your all classes is in C:\helloworld\client\code\build\classes now.
27. Go to C:\helloworld\client\code
28. Type: java -classpath C:\helloworld\client\code\build\classes;C:\tools\axis2-154\axis2-1.5.4\lib\*
29. You should get: Response : Hello John

More tutorials:

No comments:

Post a Comment