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.
Enterprise Bean Type
In [Enterprise Bean type], select [Stateless Session Bean].
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.
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.
Inherit the java.rmi.Remote interface
The method throws a java.rmi.RemoteException
Restrictions apply to the Java data types that can be specified in method arguments and return values. For details, refer to "Interstage Application Server J2EE User's Guide".
Do not overload the method
EJBObject or EJBLocalObject are not included as the argument and return value of the method
Do not define the following in elements of an array, structure, bean type member to be used in the argument and return value of the method
Local interface
Remote interface
LocalHome interface
Home interface
Timers interface
Timers handle interface
The return value of the Collection CMP finder method
Point
Interfaces can be created using the [Extract Interface] functionality.
Select the Enterprise Bean class that was created with Project Explorer.
From the context menu select [Refactor] > [Extract Interface].
In the [Extract Interface] dialog box, in [Members to declare in the interface] select the method to be published.
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.
Define the service endpoint interface information in the deployment descriptor(ejb-jar.xml)
The following Web service-related definition files must be created to publish the Web service.
WSDL file
<WSDL filename>_mapping.xml
webservices.xml
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".
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.
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.