Deploying a 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 your service class.

Prerequisites

  1. Download the jaxws-tools.jar and jaxws-rt.jar from the following locations.
  2. Place them in the CARBON_HOME/lib/extensions directory. If your JAXWS services are depending on any third party libraries, copy them into a 'lib' directory inside your .jar archive.
  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.


    @WebService
    public class ExampleService {
        @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 and this article.

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. Provide the hierarchical path of the service. This is optional. If you want to manage services separately, specifying a heirarchy is important. This allows you to customise your service EPR as you wish. And also it allows you to manage multiple versions of the same service changing only the business logic.

    Example: Consider a service "JAXWSTest"

    If no service hierarchy -> EPR is ../services/JAXWSTest

    With service hierarchy foo/bar/1.0.0 -> EPR is ../services/foo/bar/1.0.0/JAXWSTest

  3. Click Browse, and select the annotated .jar file.
  4. 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.