Once we have our project in place, let’s create our initial class. Right click on the source folder and create a new class, called Demo and click Finish.
Once we have our class, please make sure it has the following code:
package com.demo.goj; public class Demo { public String returnMessage (String name) { return "Hello " + name; } }
In this com.demo.Demo class we have defined a single method called returnMessage with a single parameter: a string that receives a name. Our method will return a simple message saying “Hello” plus the name given as parameter.
We will see how this is returned in a web service later in this tutorial.
Now, let’s use eclipse built in plugin for creating web services.
Right click on the SOAPDemo project and select New / Other
This will open a new window, in that window select Web Services – Web service and click next
The following Web Service screen should appear. Please select the class we want to expose as a web service, in our case the Demo.java class, so let’s reference it by the fully qualified class name: com.demo.goj.Demo.
On the configuration part of the screen, click on the Web Service Runtime: and select Axis2 and click OK