Deploying the JAX-WS Service

The WSO2 SOA platform provides a JAX-WS component to deploy JAX-WS annotated .jar files as Web services. It is extremely simple, and there is no need to write services.xml files. You have to write your web service class (just like a POJO) and then annotate it using JAX-WS annotations. You can then deploy it as a web service simply by creating a .jar file, which includes you service class.

Prerequisites

  1. Download the jaxws-tools.jar and jaxws-rt.jar from the following locations. [1] jaxws-tools.jar - http://www.java2s.com/Code/JarDownload/jaxws-tools.jar.zip [2] jaxws-rt.jar - http://www.java2s.com/Code/JarDownload/jaxws-rt.jar.zip
  2. Place them in the CARBON_HOME/lib/extensions directory. If your JAXWS services are depending on any third party libraries, copy them into CARBON_HOME/lib/extensions directory.
  3. Re-start the server.

Writing a Simple Annotated Web Service

First write your Web service logic as follows.

public class ExampleService {

public String reverse(String input) {

StringBuffer buff = new StringBuffer();

for (int i=input.length()-1; i>=0; i--) {

buff.append(input.charAt(i));

}

return buff.toString();

}

}

Then annotate it as follows. Compile and include it in a .jar file.

import javax.jws.WebMethod;

import javax.jws.WebService;

@WebService

public class ExamplePOJOService {

@WebMethod

public String reverse(String input) {

StringBuffer buff = new StringBuffer();

for (int i=input.length()-1; i>=0; i--) {

buff.append(input.charAt(i));

}

return buff.toString();

}

}

Note: For more information on writing JAXWS annotated web services, refer to the JAXWS Axis2 User Guide.

Uploading a JAX-WS Service

This feature is used to upload annotated .jar files and resource .jars which are dependencies used by the service implementation.

Figure 1: Uploading a JAX-WS Service

  1. In the navigator, under Manage/Service, click JAX-WS Service. The Add JAX-WS Service page appears.
  2. Click Browse, and select the annotated .jar file.
  3. Click Upload.

You can check your service on the Service List page. You can also use the tools available on this page to check the status of the service and control the quality of the service.