Submitted on October 7, 2009 - 06:13.

Within few minutes, you will learn how to create an axis2 web service using the eclipse IDE in just 3 easy steps.
The 3 steps are:
| 3.4 or higher | |
| Java | 1.5 or higher |
| WSO2 WSAS | 3.1.x |
| eclipse features |
Note: Visit the resources section of this tutorial to find out from where to download the prerequisites or click the above links.
Go to File->New->Other... (Or "Ctrl + N")
Select Dynamic Web Project.
Type in a "Project name"
In "Target runtime" if "WSO2 WSAS 3.1" not available, click "New"
Select "WSO2 WSAS 3.1" from the list and click next.
Specify WSAS distribution path.
Click "Finish"
In "Configuration" click "Modify"
Tick/Check "WSAS Web Services" and click OK
Click "Finish"
Go to File->New->Other... (Or "Ctrl + N")
Select "Class" and click "Next"
Put the package name and name of the class
Click "Finish"
Lets have the following code.
package org.wso2.sample.webservice;
public class Area {
public double getSquare(double sideLength){
double area=sideLength*sideLength;
return area;
}
public double getRectangle(double width, double height){
double area=width*height;
return area;
}
public double getTriangle(double baseLength, double height){
double area=0.5*baseLength*height;
return area;
}
}
Select the Area.java class from "Project Explorer" view which is in the left handside of eclipse workspace.
Go to File->New->Other... (Or "Ctrl + N")
Select "Web Service" click "Next"
Click "Web service runtime" link and select "WSO2 Web Services Application Server" in the "Web service runtime" list box.
Click "OK".
Click "Finish"
Thats it. Your web service (provided that there aren't any syntax or coding errors) will be published in WSAS server.
When the WSAS server starts it will open the WSAS home page of WSAS server in an external browser. You can click the "List" link under services to see which services are available in the server.
Click on the "Try this service" link infront of the "Area" service to invoke your web service.
So creating a web service is easy. All you have to do is to point to the class which you want to make it a web service.
Saminda Wijeratne, Senior Software Engineer, WSO2, samindaw@wso2.com
| Attachment | Size |
|---|---|
| create-webservice-eclipse-wsas-7.JPG | 25.81 KB |
| create-webservice-eclipse-wsas-8.JPG | 22.2 KB |
| create-webservice-eclipse-wsas-9.JPG | 31.46 KB |
| create-webservice-eclipse-wsas-10.JPG | 27.17 KB |
| create-webservice-eclipse-wsas-11.JPG | 21.3 KB |
| create-webservice-eclipse-wsas-12.JPG | 31.88 KB |
| create-webservice-eclipse-wsas-13.JPG | 40.93 KB |
| create-webservice-eclipse-wsas-14.JPG | 30.6 KB |
| create-webservice-eclipse-wsas-15.JPG | 29.94 KB |
| create-webservice-eclipse-wsas-16.JPG | 21.5 KB |
| create-webservice-eclipse-wsas-17.JPG | 32.99 KB |
| create-webservice-eclipse-wsas-18.JPG | 44.24 KB |
| create-webservice-eclipse-wsas-19.JPG | 24.5 KB |
| create-webservice-eclipse-wsas-20.JPG | 29.88 KB |
| create-webservice-eclipse-wsas-21.JPG | 34.86 KB |
| create-webservice-eclipse-wsas-22.JPG | 45.5 KB |
| create-webservice-eclipse-wsas-23.JPG | 60.36 KB |
| create-webservice-eclipse-wsas-26.JPG | 42.97 KB |
| create-webservice-eclipse-wsas-28.JPG | 33.05 KB |
| create-webservice-eclipse-wsas-Area.java_.zip | 319 bytes |
Issue with the final step of the deployment
I have Wso2 server on my machine and when i tried to follow the above steps on Eclipse EE version it gave me
java.lang.NoClassDefFoundError: and
Caused by: java.lang.ClassNotFoundException: and
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Exception in thread "main"
Do i need to set separate paths for creation of a web service on Eclipse? Any Comments or help is appreciated.
Thanks.
I think this thread is
I think this thread is http://wso2.org/forum/thread/8695 is related to this issue.