View Christos Tranoris's profile on LinkedIn

Visit The Model Driven Software Network

Who's online

There are currently 0 users and 2 guests online.

Recent comments


Syndicate content

Tutorial 1: Creating Web Services in Eclipse (Bottom Up) [Indigo]

The purpose of these series Tutorial (updated with eclipse Indigo) is to introduce tools needed, setup and initial guidelines for Service Oriented Applications. Since there are many tutorials out there, this text will provide urls that point to each step and fill any gap between them. Web Services, Service Orchestration, Enterprise Service Buses and Business Rules Engine will be explored during these tutorials. The tool that we will mainly use as development platform is Eclipse. One might debate for NetBeans 6 (i.e. for a fair comparison see It's plugin ecosystem, OSGi based architecture makes it though my personal favorite choice.
We will start by just downloading the latest version of Eclipse. Download the EE bundle. Although one could use Yoxos and create a custom Eclipse download, we will just use Eclipse's update feature and install things as we go. You will need also a JDK. During this tutorial jdk1.6.0_12 is used.
These tutorials use Eclipse Indigo version. Just unzip your Eclipse file on your hard disk. As a rule of thumb, try to have different Eclipse installations for different needs, thus making your environment lighter. I.e. don't load your Java EE Eclipse with C/C++ plugins. (I have it under C:\eclipse-jee-indigo-win32)

Creating Bottom Up web services is the most simpler way, since you just make your POJO and you let to Eclipse the hard work to create WSDL, deploy service, etc.
Before starting your web services development, we need Apache Tomcat. So, download it and install it on your machine. During this tutorial we have used Apache Tomcat 7.0.16 Server. I used Windows Service Installer (since during this tutorial is made on Windows Vista. ).
To configure your Apache Server in Eclipse,

·        Open Window -> Preferences -> Server -> Runtime Environments to create a Tomcat installed runtime.
·        Click on Add... to open the New Server Runtime dialog, then select your runtime under Apache (Apache 7.0 from the list). “Create a new local server” must be checked when adding the Apache Tomcat runtime environment. (This is usefull so not to mess up your actual web services with your web services that you are developing and testing)
·        Put your Tomcat installation dir e.g. C:\Program Files\Apache Software Foundation\Tomcat 7.0 and finish.
·        In the Servers view panel, you will see the Tomcat server Stopped. In the Project Explorer view, a Server configuration will appear.
·        If you run the Server you might encounter an error if your Tomcat is already running. So you must configure different ports for your installation , otherwise you must stop your Tomcat server while you are developing and testing your web services. If you double click the server, the local configuration will appear. Change the ports as you wish and the Right Click the server Icon and select Start to start the server. (Click Unblock on any firewall notices)
 Before continuing we will need Apache Axis( an implementation of the SOAP). Download it from here. (This tutorial uses axis2-1.6.0)
Save it for example on c:\axis2-1.6.0 and point Eclipse WTP to downloaded Axis2 Runtime. Open Window -> Preferences -> Web Services -> Axis2 Preferences and put there the path of Axis2.
On preferences check Generate an interface for the skeleton and Click OK
A nice Creating Bottom Up Web Service tutorial could be found here with similar action. However in this tutorial things are updated.
Create a project "ResourceA" with the support of Axis2 features. Open File -> New -> Dynamic Web Project

 On the configuration click Modify..and check the Axis2 Web Services (check also Dynamic Web Module version 2.5), click OK and Finish
Create a package named pkg (Right click on Java Resources ->New->Package) and a class name MyService (Right click on Java Resources->New->Class) . At the end you will have something like the following:

 Write the small Java code:
public class MyService {
public MyService() {
public Boolean Configure(String param, String val){
return true;
public Boolean StartMe(){
return true;
public Boolean StopMe(){
return true;
public String getStatus(){
return "No status available!";
Save it and Select the file Right click and (down on the menu) Web Services -> Create Web Service
On the window that appears just click the Web Service Run Time and on the dialog select Apache Axis2

Click Next and leave the default services.xml.
Click Next and if prompted Start the server (remember here the ports otherwise the server will not run!)  If something goes wrong, just procced, finish the wizard and then go to the Servers and Right click to start the Tomcat server at localhost)
The ResourceA now is deployed and start in our Tomcat server (remember the Eclipse copy of Tomcat (listens on 8081) not your system Tomcat (listens on 8080))
Now if you Select the ResourceA project, right-click and select Run -> Run As -> Run on Server you will go to http://localhost:8081/ResourceA/ (At the first time you run this wizard, you need to specify the Tomcat. You can check on Always use this server when running this project)
You will get the home page:
Click on services. Check that your web service is Active. Check also the available Operations:

 If you click on the MyService link you will get the WSDL of your service (http://localhost:8081/ResourceA/services/MyService?wsdl)
 Copy this link on your clipboard.
Go to menu Run-> Launch the Web Services Explorer, and select from the icons the WSDL

Click on WSDL Main and paste the wsdl address, click Go.

The service will open. Just go for ie MyServiceSoap11Binding find the getStatus and click Go. A Soap call will be invoked and the message in the Body of the response will appear.

During this tutorial we created our first Web Service with Eclipse Web Tools Platform. In this tutorial here a Java client is also created that utilizes a web service.
To deploy your service on your Tomcat server, just right click the project ResourceA choose Export->WAR file.
Probe further:
The alternative way of Top-Down can be found in other tutorials. Check also a nice tutorial here.
Here you can find a nice getting started guide with Web Tools Platform. 

Posted in Submitted by tranoris on June 28, 2011 - 10:27.

Anonymous | September 26, 2011 - 21:39

I've followed your tutorial and when I proceed to create the Webservice, I get the following error:

[INFO] The DaisyWebservice service, which is not valid, caused java.lang.NoClassDefFoundError: org/outerj/daisy/repository/Repository

- the JARs are present in my library
- they get imported (and get resolved)
- I even copied them in the lib folder of Tomcat 6.5

Should the JARs be present somewhere else? What am I missing?

Also, about the web service not being valid... would the fact that I haven't done the necessary exception handling be the cause of this?



Anonymous | October 6, 2011 - 05:15

Which versions of your software are you using, that is Eclispe, Axis2 and Tomcat?

It IS important to use the right version.

Do you get more errors from the Javaservlet Console (Tomcat console)?