Monday, December 7, 2009

JAX-WS Web Services with JBoss (JBossWS)

Today, Web Services are an essential part of every developer’s toolkit not only because they have diverse and varied applications but because they are easy to create and consume and work like a charm. Whether it is about inter-communication between legacy applications and new ones or there might be a scenario in which two applications (programmed in different languages) need to interact, Web Services come to your rescue. In short, Web Services are everywhere and you cannot imagine your life without them, especially if you are a Web Developer.

So, without wasting any more time on Web Services as there are many good resources for introducing them (see resources below), lets see how to create the environment needed to develop these Web Services. (Sometimes, I feel that creating an environment for developing and deploying Java apps is more tedious process than actually coding for the application :-) )

What is JAX-WS ?

JAX-WS stands of Java API for XML – Web Services; it is the latest standard/specification created for development and maintenance of web services. It is a successor to JAX-RPC and you can read here about the differences between the two. JAX-WS bring along many improvements, but for one, it is too easy to create, deploy and consume than its earlier counterpart.

What is JBossWS ?

We will use JBoss Application Server to deploy our application and hence we will use their Web Service Stack. JBossWS (JBoss Web Services) is in short, an implementation of JAX-WS specification.

Software that we require:

  1. JDK 1.5 and above (We use JDK 1.6)
  2. JBoss Application Server (We will use JBoss5.1.0 with JDK 1.6)
  3. JBossWS Web Service Stack (We use JBossWS Native Stack)
  4. Ant (Java Build/Automation Tool)

So, lets set up the environment around us so that we can easily create new and happening web services.

Step 1

Download and Install JDK on your machine (if not already installed). Also set your environment variable JAVA_HOME to the installed JDK location. Also add it to PATH environment variable. To check if this step is done properly, check by typing on command line:
>>> java –version

It will show you something like this (your current java version) and because you set the PATH variable, you can do this from anywhere:


Step 2

Download and install ANT (a Java based Build Tool). If you are new to ANT, check my earlier blog entry about ANT to gain more insight. Again, set ANT_HOME to installation path and also include ANT_HOME in PATH variable. To check, type on console:
>>> ant -version

It will show the current version of ANT installed, something like this


Step 3

Download JBoss 5.1.0 with JDK 1.6 from here and install it on your system. Now, set JBOSS_HOME = {Installation path}
check by starting and stopping server. Pretty simple so far.

Step 4 

Download JBossWS Web Service Stack. Note that JBoss application server alone is not enough to deploy your web-services so you need additional jars that help you create, deploy, maintain and consume your JBossWS Web Services.

Download the binary distribution of JBossWS-Native 3.2.1 GA from here. Now, lets see how to install this pack.
Installing jbossWS pack requires:

1. Copy to (Creating a backup)

2. Change following in (this file is used by build.xml)

   a) Location of your JBoss

(since we are using JBoss5.1.0 so replacing that constant with real value)

3. Now run the ant script from command line specifying the target according to the version of JBoss you are using.

   >> ant deploy-jbossXXX  (replace XXX with your version of jboss)
   >> ant deploy-jboss510

It will run the build.xml file and execute all the tasks mentioned in it in the specified manner. If at the end, it prints BUILD SUCCESSFUL, then it means that you have successfully installed the web service pack. :-)

To confirm that it has installed correctly, check the following url (assuming that JBoss works on 8080 for you): http://localhost:8080/jbossws/

jbossWS If you see a picture similar to what is embedded here, it means that JBossWS Web Service Pack is installed successfully on your system and you are ready to create more. This URL acts as a console to manage your currently deployed web services.


It is not necessary that you need JBoss to deploy JAX-WS Web Services. With the advent of JDK1.6, you can also use Tomcat server to host these web services as JDK1.6 is already shipped with JAX-WS jars, although the procedure to create and deploy such services will differ from that of JBossWS. 

In the next blog entry, I would give an example of creating a simple web service using JBossWS Web Services. The actual purpose of this blog entry is to prepare you for the big picture !!


  1. Introduction to Web Services (Must read for any Beginner)
  2. Web Services Architecture
  3. JAX-WS Reference Implementation (a really detailed one !!)
  4. Comparison between JAX-WS and JAX-RPC
  5. Download JDK1.6
  6. Download ANT
  7. Download JBoss Application Server
  8. Download JBossWS-Native (Web Service Stack)

No comments: