JAX-WS Webservices


This article will briefly describe how to create a JAX-WS webservice with JBoss 5.1 and how to avoid JAXB serialization/deserialization problems that might arise during the deploy process of the webservice.

JAX-WS stands as an acronym for Java API for XML Web Services and is a Java API for creating web services and is a part of Java EE platform from Sun Microsystems. It is the latest standard/specification created for development and maintenance of web services. It is a successor to JAX-RPC.

JBoss 5.1 is already shipped with JAX-WS jars, and it makes the procedure to create/deploy a web service very simple.

Suppose we want to expose a regular Java class a a web-service (this class should reside in a dynamic web project)

For this, we will use some annotations from the javax.jws package:

  • we will annotate the whole class with the @WebService annotation
  • we will annotate the method(s) in the class that we want to expose as web service methods with the @WebMethod annotation
  • the parameters that an exposed method receives need to be annotated with the @WebParam annotation

The class should look like:

package com.company.testWS;
@WebService(name = "MyWebService")
public class MyWebService{
  public Reply testMethod(
      @WebParam(name = "firstParam") String firstParam,
      @WebParam(name = "secondParam") Integer secondParam) {

Once the code is ready and compiled, we have to modify the web.xml file located in WEB-INF folder.
The newly created web service class needs to be declared as a servlet inside the web.xml


The web.xml will be used then as a descriptor for deploying the Web Service.

Now,when the web application is deployed on JBoss, this web service is automatically set up by JBoss.

To make sure web service is started you should find in the JBoss console  a log like below

14:35:52,306 INFO [ServiceEndpointManager] WebService started: http://<machine name>:8080/<web project name>/MyWebService

To view the WSDL for this new web service follow this link http://<machine name>:8080/<web project name>/MyWebService in your browser.

To see a list of all deployed web services on JBoss, follow the link http://localhost:8080/jbossws

Clicking on View a list of deployed services will list you the deployed web services.

Problems that might appear

One problem i hit once while working with JAX-WS web services on JBoss was that the parameter(s) a web service method receives could not be serialized/deserialized correctly by JAXB.

The error that i encountered was:

java.sql.Timestamp does not have a no-arg default constructor

This is a requirement in JAXB, that all classes used as web service parameters need to have a no argument default constructor, (because otherwise JAXB wouldn’t know how to instanciate it). java.sql.Timestamp does not have one, so we have the complaint.
The solution is to write an ‘adapter’ class that extends XmlAdapter and transforms this problematic class into basic types that JAXB knows how to handle. We can transform this Timestamp into java.lang.Long by using the timestamp values in miliseconds to represent this Timestamp as a Long entity.
The adapter class will look like:

public class TimestampAdapter extends XmlAdapter < Long, Timestamp > {
  public Long marshal(Timestamp timestamp) throws Exception {
    return timestamp.getTime();
  public Timestamp unmarshal(Long milis) throws Exception {
    return new Timestamp(milis);

Now, in order to use this adapter for the class types that have no argument constructor, we use the annotation @XmlJavaTypeAdapter right above the field declaration (you can use this annotation also above the getter or setter methods for this field, but that is more work to do).  If this java.sql.Timestamp is a member variable inside a class, the whole class should be annotated with @XmlRootElement and @XmlAccessorType. For example:

public class MyClass {
  private Timestamp timestamp;

Now your web service should deploy with no more errors regarding JAXB.

Finally, there’s another very important peculiarity of what does Cialis that brings it so high above its alternatives. It is the only med that is available in two versions – one intended for use on as-needed basis and one intended for daily use. As you might know, Viagra and Levitra only come in the latter of these two forms and should be consumed shortly before expected sexual activity to ensure best effect. Daily Cialis, in its turn, contains low doses of Tadalafil, which allows to build its concentration up in your system gradually over time and maintain it on acceptable levels, which, consequently, makes it possible for you to enjoy sex at any moment without having to time it.

By continuing to use the site, you agree to the use of cookies. More information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.