Concept: Web Services for J2EE
This guideline provides an overview of J2EE Web Services.
Related Elements
Main Description

What is a J2EE Web Service?

A Web Service is organized around an architecture containing three main elements: the Service Registry, the Service Provider, and the Service Requester. Figure 1 gives an overview of the relationship between these different elements.

web service architecture
Figure 1: - Web Service architecture

The Service Provider starts by defining the Service Interface through an abstract Service Description document using the Web Services Description Language (WSDL). This abstract description is associated to transport and encoding bindings, and to an address in a concrete Service Description to define a concrete Service instance also called Service Endpoint or Port. This concrete description can then be published in a Service Registry such as Universal Description, Discovery and Integration (UDDI) to be accessed by any Service Requester. A Service Requester will use it to select and use a concrete Service Implementation for the Web Service.

A J2EE Web Service consists in a set of such Ports operating within a container. The container mediates access to the service and provides the runtime environment.

A client of a Web Service can be another Web service, any J2EE component, or an arbitrary Java application. Even non-java or non-Web applications can use Web services.

Web Service Client View

The Web Service client view is provided by the Port Provider (Service Provider) and by the container. As shown in the Figure 2 below (in gray), the client view comprises a Service Interface and a Service Endpoint Interface.

view of web service client
Figure 2: - Web Service client view

To access a Port of a Web Service, the client starts by locating the Service Interface using the JNDI APIs. Through the Service Interface, the client will discover the methods to use to access a Port and access the Web Service implementation using the Service Endpoint Interface. In the client view a Port is considered as a stateless object.

The Service and Service Endpoint Interfaces are defined by the JAX-RPC specification; however, the Service Interface behavior is defined by the WSDL Service Description document provided by the Web Service Provider.

Web Service Server View

The server view of a Web Service deals with the implementation of the business logic of the service. As defined in J2EE 1.4, Web Service Endpoint can be implemented using one of the following approaches:

  • Using a stateless session bean as specified in the JSR 109 and EJB 2.1 specifications
  • Using a servlet as specified in JAX-RPC

For more information on this two approaches, see Guideline: Identifying Session Beans for session bean-based endpoint, and Guideline: Identifying Servlets for servlet-based endpoint.


The main reference for this page is the Web Services for J2EE (JSR 109) specification.