Chapter 4. Creating and Deploying Web Services

Table of Contents

4.1. Overview
4.2. Creating and Deploying Java Class Web Services
4.3. Creating and Deploying EJB Web Services
4.4. Creating and Deploying WSDL Web Services
4.5. How to Determine an Endpoint Address
4.5.1. Servlet Endpoint
4.5.2. EJB Endpoint

This chapter describes how to create JAX-WS web service applications from Java class and WSDL files, how to deploy and package them, and how to manage them in JEUS 7.

The process for deployment is almost the same as for any other web services implemented either from Java class or WSDL file. Since JAX-WS web service implementation is POJO web service-oriented, there is much less number of deployment descriptors than in a JAX-RPC web service.

JAX-WS web services can be programmed without using a deployment descriptor, which was generally used for the implementation of JEUS 5 JAX-RPC web services. This enables a developer to develop web services more conveniently and rapidly (Descriptor free programming).

Creating a web service, implemented from Java classes, as a WAR file involves binding service endpoint implementation classes and other Java classes (portable artifacts) used by the implementation class with multiple deployment descriptor (DD) files into a WAR format.

The following shows the web service implemented from the Java classes from the previous chapter in a WAR format grouped by directory.

META-INF/MANIFEST.MF
WEB-INF/classes/AddNumbersImplService_schema1.xsd
WEB-INF/classes/AddNumbersImplService.wsdl
WEB-INF/classes/fromjava/server/AddNumbersImpl.class
WEB-INF/classes/fromjava/server/jaxws/AddNumbers.class
WEB-INF/classes/fromjava/server/jaxws/AddNumbersResponse.class

As shown in the previous example, the WAR file consists of a service endpoint implementation class, portable artifact classes, and the web.xml file, which is the only DD file. The web.xml file is not required to implement a JAX-WS web service, but it is used here to obtain a preferred endpoint address. For more details about endpoint addresses, refer to "4.5. How to Determine an Endpoint Address".

The web service WAR file can be accessed when it is deployed using the method provided by JEUS 7. Enter the following command in the console to deploy the WAR file in JEUS 7.

$ ant build deploy

The following is the actual address for accessing the service after a successful deployment.

http://host:port/AddNumbers/AddNumbersImplService

Creating a web service, implemented from a Java class, as a JAR file involves binding a service endpoint implementation class and other Java classes (portable artifacts) used by the implementation class with multiple DD files into a JAR format.

The following shows the web service implemented from the stateless session beans from the previous chapter in a JAR format grouped by directory.

META-INF/MANIFEST.MF
fromejb/server/AddNumbersImpl.class
fromejb/server/jaxws/AddNumbers.class
fromejb/server/jaxws/AddNumbersResponse.class

As shown in the previous example, the JAR file consists of service endpoint implementation and portable artifact classes. For more information about endpoint addresses, refer to "4.5. How to Determine an Endpoint Address".

The web service JAR file can be accessed when deployed by using the method provided by JEUS 7. To deploy the JAR file in JEUS 7, enter the following command in the console.

$ ant build deploy

The following is the actual address for accessing the service after a successful deployment.

http://host:port/AddNumbersImplService/AddNumbersImpl

Creating a web service, implemented from WSDL, as a WAR file involves binding a service endpoint interface, its service endpoint implementation class, and other portable artifacts with multiple DD files into a WAR file format.

The following shows the web service implemented from the WSDL from the previous chapter in a WAR format grouped by directory.

META-INF/MANIFEST.MF
WEB-INF/wsdl/AddNumbers.wsdl
WEB-INF/classes/fromjava/server/AddNumbers.class
WEB-INF/classes/fromjava/server/AddNumbersImpl.class
WEB-INF/classes/fromjava/server/AddNumbersPortType.class
WEB-INF/classes/fromjava/server/AddNumbersResponse.class
WEB-INF/classes/fromjava/server/AddNumbersService.class
WEB-INF/classes/fromjava/server/ObjectFactory.class
WEB-INF/classes/fromjava/server/package-info.class

As shown in the previous example, the WAR file consists of the service endpoint interface (AddNumbersPortType), an implementation of the interface (AddNumbersImpl), multiple portable artifact classes, and a single DD file, web.xml. The web.xml file is not required to implement a JAX-WS web service, but they are used here to obtain a preferred endpoint address. For more information about endpoint addresses, refer to "4.5. How to Determine an Endpoint Address".

The web service WAR file can be accessed when deployed using the method provided by JEUS 7. To deploy the WAR file in JEUS 7, enter the following command in the console.

$ ant build deploy

The following is the actual address for accessing the service after a successful deployment.

http://host:port/AddNumbers/AddNumbersService

In JEUS 7, a JAX-WS web service can be deployed without any deployment descriptor file (descriptor-free), such as web.xml or webservices.xml file, which was required in JEUS 5.

This section discusses how to determine an address to access a JAX-WS web service when the service is deployed to JEUS 7, for servlet based and EJB based web services.

A servlet endpoint URL is determined in the following priority order.

  1. When using the <url-pattern> element in web.xml

    The <url-pattern> element in the web.xml file is used to configure the web service URL. This value overwrites the default value of @EndpointDescription endpoint address.

    The following is an example of the web.xml file that configures the endpoint class named AddNumbersImpl.



    The following is the actual URL for the web service.

    http://server:port/context/addnumbers
  2. When using the @EndpointDescription Annotation

    If an endpointUrl variable is specified in the @EndpointDescription annotation, its value is the URL for accessing the web service. The value overwrites the default serviceName endpoint address in the @WebService annotation.

    The following is an example of an endpoint class.


    The following is the actual URL for the web service in this example.

    http://server:port/context/MyService
  3. When using the serviceName attribute of the @WebService Annotation

    If a serviceName variable is specified in the @WebService annotation, its value is the URL for the web service. This value overwrites the default endpoint address.

    The following is an example of an endpoint class.


    The following is the actual URL for the web service.

    http://server:port/context/AddNumbers
  4. Default value of an endpoint address + "Service"

    If nothing is specified but the @WebService annotation, the default value of the web service endpoint address is the endpoint class name + "Service".

    The following is an example of an endpoint class.


    The following is the actual URL for the web service.

    http://server:port/context/AddNumbersImplService 

The priority order for determining the EJB endpoint URL is the same as that of the servlet endpoint, but the method for determining the context is different.

The context is determined in the following priority order.

  1. When using the @EndpointDescription Annotation

  2. When using the serviceName attribute of the @WebService Annotation

  3. Default value of the context

    • Context

      The default value of a context is the service name (ServiceName) from the WSDL document of the web service. The default service name is specified by adding 'Service' to the endpoint class name.

      The following is the address for the web service of this endpoint class.

      http://server:port/AddNumbersImplService/AddNumbersImpl