Top
Interstage Studio User's Guide
FUJITSU Software

D.2.8 Exposing a Stateless Session Bean as a Web Service

This section explains the procedure for exposing a stateless session bean as a Web service.

(1) Creating Stateless Session Bean

Creating a Project

Refer to "3.3.1 Preparing the Environment to create EJBs" for information on creating projects.

In this case, select [2.1] for [EJB Module version].

Creating an Enterprise Bean

Create an Enterprise Bean with the [New Enterprise Bean] wizard.

  1. Enterprise Bean Type
    In [Enterprise Bean type], select [Stateless Session Bean].

  2. Interface Creation Options
    If creating a stateless session bean, select [Generate LocalHome/Local interface]. If a stateless session bean will be invoked from a Web service only, the localhome/local interface is not required. However, in this case, select [Generate LocalHome/Local interface].

    Note

    Remote access via the home/remote interface is not supported for EJB2.1 Applications that run on Interstage Application Server.

  3. Business Method Definition

    Define the method that the Web service will publish. After the wizard finished, implement the method that was defined in the created Enterprise Bean class.

Creating a Service Endpoint Interface

Create a service endpoint interface from the Enterprise Bean class that was created.

Ensure that the following conditions are met in the service endpoint interface.

Point

Interfaces can be created using the [Extract Interface] functionality.

  1. Select the Enterprise Bean class that was created with Project Explorer.

  2. From the context menu select [Refactor] > [Extract Interface].

  3. In the [Extract Interface] dialog box, in [Members to declare in the interface] select the method to be published.

  4. Correct the created interface so that the conditions of the service endpoint interface are met.

(2) Exposing a stateless session bean as a Web service

The following measures are required when exposing a stateless session bean as a Web service.

By using the Web service wizard, updating and creating the above files can be performed automatically from the service endpoint interface.

Exposing a Stateless Session Bean as a Web service with the Web service wizard

Expose a stateless session bean as a Web service with the Web service wizard. For details on the wizard, refer to "Generating the files required for a Web service".

  1. Source Folder
    In the [Source folder], specify the source folder of the Enterprise JavaBeans project that you need to expose as Web service. A project that is not Enterprise JavaBeans version 2.1 cannot be specified.

  2. Service Endpoint Interface Name
    Specify the name of the service endpoint interface that was created.

Point

When a stateless session bean is exposed as a Web service, the Enterprise Bean class becomes an implementation class, therefore setting the implementation class name is not required.

Note

If you try to expose the following Enterprise JavaBeans as a Web service, an error will occur in the wizard.

  • If implementing identical service endpoint interfaces in multiple Enterprise Bean classes

  • If registering the same Enterprise Bean class with different EJB names

(3) Packaging to the EAR File

If deploying a stateless session bean that has been exposed as a Web service, perform packaging to the EAR file.

(4) Deployment

Deploy the created EAR file to the Interstage Application Server J2EE execution environment.

Note

If an EAR file contains a Stateless Session Bean that has been exposed as a Web service, deploy the EAR file to the J2EE execution environment shown below. Deployment fails if attempted for a different J2EE execution environment.

  • Run the Web application and EJB application on the same Java VM.

Point

If a stateless session bean that was exposed as a Web service is deployed to the IJServer, a Web application named "EJB SOAP router" will be integrated automatically.

If running a stateless session bean that was exposed as a Web service, a servlet for the purpose of transmitting a request from SOAP (HTTP) is required. This servlet is called an "EJB SOAP router".

For every EJB JAR file which includes a stateless session bean that was exposed as a Web service, one EJB SOAP router is created.