Create web services for stateless session beans in Rational Software Architect

Learn how to create, publish, and test the web services of stateless session beans

Learn how to create web services for stateless EJB session beans in IBM® Rational® Software Architect. This tutorial shows you how to use the easy tooling capabilities of Rational Software Architect to create a web service, and then test it using web services test explorer.


Jinu Mohan, Integration developer, IBM China

Jinu Mohan is an Integration Developer and specialized in Java and J2EE based technologies. His Professional Software development experience was mainly focused on Developing J2ee applications on Rational Application developer and administrating WebSphere Application Server.He recently worked on Analyzing and Development of Automation framework for IBM B2B Products. Jinu currently works for Industry Solutions group in IBM. Jinu is a Certified professional for WebSphere Application Server 6.1.

29 August 2011

Also available in Japanese

Before you start

About this tutorial

This tutorial describes the different ways of creating web services for EJB stateless session beans in Rational Software Architect, and how to test the web services using the web service test explorer. An EJB sample application is provided.


The main objective of this tutorial is to provide details on creating JAX-WS and JAX-RPC web services using Rational tolling.


You should have a beginner to intermediate level knowledge on EJB 3.0 and web services.

System requirements

To complete the steps in this tutorial, you need:

  • Rational Software Architect 7.5 and above
  • Websphere Application Server 7.0

EJB stateless session bean as web service

Getting started

  1. Import the sample DateFormatter (EJB 3.0) project provided in the downloads.
  2. This project has a stateless session bean named DateFormatterService already created in it.
  3. The DateFormatterService has the service method which formats the given date object into a String whose format is "EEE, MMM d, yyyy"

Creating the web service

Now we will expose the "formatDate" method in the DateFormatterService bean as a web service. Though JAX-WS is advanced version of Web Service we will look into JAX-RPC version as well.


  1. To create a JAX-WS web service, add an annotation @WebService just above the @Stateless anotation in the DateFormatService bean. Building the project creates a service under services.
Figure 1. DateFormatService bean
DateFormatService bean
  1. Add a router to transfer the soap messages over http. Right-click the service that is created under services and select Create router module(EndpointEnabler). In the Create Router Modules window, select EJB Web Service binding as HTTP. Select finish. This creates a DateFormatter_HTTPRouter.
    Figure 2. Create router project
    Create router project

Done! You have created JAX-WS web service for stateless session bean.


  1. After importing the project, right-click DateFormatterService bean, Web Services > Create web service.
  2. In the Web Service creation window, provide the following values:
    • Web service type: Bottom up EJB Web Service
    • Service implmentation: DateFormatterService
    • Web service runtime: IBM Websphere JAX-RPC
    • Service project: DateFormatter
    • Service EAR project: DateFromatterEAR
  3. In the first slidebar, slide till "Assemble service" and in the second, slide to "No client".
  4. Click next. In the Web Service EJB configuration select HTTP bindings.
  5. Click next. In the Web Service EJB identity window select the method which is to be exposed as web service.
    Figure 3. Web Service EJB identity
    Web Service EJB identity
  6. As we are not publishing this service to a UDDI registry, click finish.

Done! You have created JAX-RPC web service for stateless session bean.

Testing the web services

  1. After creating the service, you are ready to test the web service using the test explorer, provided the application is added to server. Right-click on the service which is created(DataFormatter > Services > <service name>) and select Test with Web Services Explorer.
  2. Once the explorer opens, in the left panel, select the operation(formatDate here) to be executed.
Figure 4. Web Service Explorer
Web Service Explorer
  1. Provide the input date and click on Go button.
Figure 5. Invoke operation
Invoke operation


Sample code for this tutorialSample_code_DateFormatter.zip7KB



developerWorks: Sign in

Required fields are indicated with an asterisk (*).

Need an IBM ID?
Forgot your IBM ID?

Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.


All information submitted is secure.

Dig deeper into SOA and web services on developerWorks

Zone=SOA and web services
ArticleTitle=Create web services for stateless session beans in Rational Software Architect