WebServices in Eclipse

I’ve been teaching a few classes on Web Services lately and my students have complained that there are no good description on the net for how to get started building web services on Eclipse. I’m sure there are some, but I was encouraged to create one myself, so here it is. I also wanted to try out Captivate 5 properly, so most of this tutorial/blog will involve videos found on YouTube and separately on our e-learning site.
I’ll basically take you through the following two steps:

  1. How to download and install the required tools?
  2. How do I configure Eclipse to develop and run web services?
  3. How do develop a simple Web Service?
  4. How to deploy your Web Service?
  5. How to test your Web Service?

I decided to use videos for this… So, each section is a separate little demo in the form of a Flash movie (sorry iPhone users… I may put the movies on YouTube later to make sure you can see them too).

Downloading and installing the required tools

The first thing we need to do is to download and install the tools required. The tools I’m going to use are:

  • Apache Tomcat
  • Apache CXF
  • Eclipse JEE version

The steps of this video shows you how to:

  1. Download the tools
  2. Install the tools
  3. Start up eclipse

I’ve put the presentation on YouTube, but because of Adobe Captivates lack of support for the YouTube formats (they don’t support HD videos export), the quality is rather poor. You can (if you tolerate the back button on you browser) also view a high-quality version by clicking on this link (HIGH RESOLUTION DEMO).

Configure Tomcat

In the previous video we came as far as starting up Eclipse. We have Tomcat and CXF installed, and we now need to configure Eclipse so that it knows where our Tomcat and CXF installations are. Please note that if you change workspace, you will have to do this all over again (or save the preferences to a file, then restore them in your new workspace).
Again, I decided to do this through a video demo. If you want a high quality version click on this link (HIGH RESOLUTION DEMO).

Test Tomcat

The next thing we'll do is to ensure that Eclipse and Tomcat is properly installed and configured. I'll just create a simple servlet to do the test. You may want to skip this demo all together if you want to get to Web Services as quickly as possible.
Again I've created a video to demo the concepts. Again, the YouTube version is of inferior quality, but if you want to see it in high def... here's the link (HIGH RESOLUTION DEMO).

Configure CXF

Tomcat is setup to run Axix web service framework by default. We want to change it to use the CXF framework that we downloaded. In this demo I'll show you have to do that. The steps involved are:

  • Add CXF to the Web Service Runtimes
  • Configure Tomcat to use CXF

As before you can watch this at YouTube (picture below) or in high definition here (HIGH RESOLUTION DEMO).

Creating a Web Service

All the steps up to here had nothing to do with Web Services. The steps prior to this has been about setup (download the tools, configure Eclipse, testing to ensure everything works).
We’ll create the simplest of Web Service… We’ll call it DeepThought. The service will have one method

The web service implementation will provide the answer to the universe, life and everything in a String.
If you want a high definition version of this demo, here’s the link (HIGH RESOLUTION DEMO).


This blog entry showed you how to download, configure and develop a web service using Eclipse, Tomcat and Apache CXF. The process involves quite a few steps. You have to:

  • Download the tools (Apache Tomcat, Apache CXF, Eclipse)
  • Install the tools (Mostly a matter of unzipping the archives you downloaded)
  • Configure Eclipse (Where is Tomcat and CXF, Configure Tomcat to use CXF, etc)
  • Create a Java implementation of your service
  • Build the web service

Although I’m sure in a few months the description will be slightly outdated (new wizards in Eclipse, etc.), I hope you’ll find the tutorial useful.

No Comments Yet.

Leave a comment