Chapter 10. Web services scenario 305
Using two phases is done for development and testing purposes only. It is easier
to ensure the application is working as designed before introducing the extra
layer of the ESB.
The ITSOMart scenario uses three Web services: CreditCheck in
CreditCheck.ear, HomeDelivery in DeliverySystem.ear, and BusinessDelivery in
DeliverySystem.ear. Each Web service was built in a similar manner. This
section illustrates how the CreditCheck service was built.
The process takes CreditCheck, an existing application, and creates a Web
service from it. We guide you through the process of creating the WSDL
document, the proxy classes, and testing the generated server code using the
Web Services Explorer. We then go through the process of creating a Web
service client that can be incorporated into a requester application to access the
new Web service. We test again to ensure that the client and provider are
working correctly. Last, we define the services to the service integration bus and
regenerate the clients to call the service using the service definition on the bus.
10.5.2 Creating a Web service from a session bean
In this section, we create a Web service using the bottom-up development
method using CreditCheckEJB as input.
Note: The following process ensures that the Web services developer
capability is enabled in the workbench:
1. Select Window Preferences.
2. Expand Workbench and select Capabilities.
3. Check the Web Service Developer box and click OK.
For information about downloading the sample application, see Appendix B,
“Additional material” on page 485.
Preparation: This sample assumes that the CreditCheck application has
been imported into the Rational Software Architect workspace. This is the
existing application that returns a credit rating and contains an EJB called
CreditCheckEJB.
We use SOAP over HTTP as the transport mechanism. A Web router project
is required with a servlet to route the client requests to the session EJB.
Before starting this procedure, create a dynamic Web project called
CreditCheckRouter and put it in CreditCheck. You will need to have this in
place before starting the Web Service wizard.
306 Patterns: Implementing Self-Service in an SOA Environment
To initiate the Web Service wizard on our EJB:
1. Switch to the J2EE Perspective.
2. In the Project Explorer view, navigate to
CreditCheckEJB/ejbModule/com.ibm.patterns.creditCheck/
CreditCheckBean.java. Right-click to bring up the context menu.
3. Select Web Services Create Web Service.
See Figure 10-9.
Figure 10-9 Web Service wizard: Web services
On the Web Services page, select the following options (Figure 10-9):
Select the Web service type EJB Web Service.
–Select Start Web service in Web project.
In our scenario, we cleared the Launch Web Services Explorer to
publish this Web service to a UDDI Registry, because we are not using
a UDDI in our test environment. Note that you can use the Web Services
Explorer (included in Rational Software Architect) later to publish the Web
service.
Note: If you cannot find Web Services on the context menu, verify that the
Web service capability is enabled.
Chapter 10. Web services scenario 307
Clear Generate a proxy. The wizard generates client proxy classes
enabling simple method calls in a client program to call the Web service.
These classes are generated based on the WSDL created for the Web
service. Because we plan to use the bus as a destination for the Web
service, new WSDL for the Web service will be created when we configure
the bus. For now, we do not want to create a proxy for the client.
Clear Test the Web service. This option lets you test the Web service
using the Web Services Explorer before the proxy is generated. It also
enables you to create a test client (a set of JSPs) in a client project.
Clear Monitor the Web service. This option lets you monitor your Web
service using the TCP/IP Monitor by routing the traffic through the monitor
and configuring the monitor for the server on which the service is
deployed.
4. Click Next to proceed to next page. On the Object Selection page
(Figure 10-10), you can specify from which Java bean the Web service is
generated.
Figure 10-10 Web Service wizard: object selection
Ensure that the EAR project selected is CreditCheck.
Select the CreditCheck for the EJB beans and CreditCheckEJB Project
from list.
Click Next.
5. On the Service Deployment Configuration page (Figure 10-11 on page 308),
specify the deployment settings for the service and the generated test client, if
you chose to create one.

Get Patterns: Implementing Self-Service in an SOA Environment now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.