426 Patterns: Implementing Self-Service in an SOA Environment
12.4.3 Create the EJB Web service client
The process of generating a Web service client is detailed in , “Creating an EJB
Web service client” on page 317. This section does not go into details on those
steps already covered, but tell yous how the Web service client was generated
for the JCA portion of the ITSOMart application.
To do this we completed the following tasks:
1. Create an EJB project
2. “Create a stateless session bean” on page 427
3. “Import the WSDL files” on page 427
4. “Create a namespace mapping file” on page 427
5. “Generate Web service client” on page 428
Create an EJB project
1. In the workbench, select File New Other EJB Project in the tool bar.
2. Provide the name of the project, JCAClient. Click Show Advanced.
Make sure EJB version is 2.1 is selected and the target server is
WebSphere Application Server v6.0.
–Check Add module to an EAR project and select the Processor EAR
project.
Uncheck Create an EJB Client JAR project to hold the client
interfaces and classes.
3. Click Finish.
Note for users of the service integration bus: The Web service client is
built using WSDL files that describe the Web service. This section assumes
you are using the WSDL generated by the Web Service wizard in the previous
section. However, in our runtime configuration, we plan to use the WebSphere
Application Server service integration bus as an intermediate destination point
for the Web service. During the bus configuration, new WSDL for this Web
service will be created, pointing to the bus as the endpoint. This process is
outlined in 12.5.3, “Configure the bus for the Web service” on page 438. If you
are using the service integration bus, you should deploy the Web service,
define it to the bus, and generate the new WSDL before generating the Web
service client.
Chapter 12. J2EE Connector Architecture scenario 427
Create a stateless session bean
1. In the workbench, select File New Other EJB Enterprise Bean in
the tool bar.
2. Click Next.
–Select Session bean.
EJB project: JCAClient
Bean name: JCAWSClient
Default Package: com.ibm.patterns.jcaService
3. Click Next and select Local client view.
4. Click Finish.
Import the WSDL files
The WSDL files need to be imported into the workspace. If you are using the
service integration bus for Web services, the WSDL must be exported from the
application server first. See “Export the new WSDL from the bus to generate the
client” on page 440.
Before starting this process, create a new folder called wsdl in
JCAClient/ejbModule/META-INF.
To import the MartJ2CBeanImplInboundService WSDL do the following:
1. In toolbar select File Import.
2. In the dialog box, select Zip file and click Next.
3. In the next screen:
a. Specify the location of the zip file containing the WSDL.
b. Make sure the WSDL files are selected.
c. Select the project to import the WSDL files into. We want to import the files
to JCAClient/ejbModule/META-INF/wsdl.
d. Click OK.
e. Click Finish.
Create a namespace mapping file
Refer to “Create the namespace mapping files” on page 345 for information
about creating namespace mapping files.
1. Under the META-INF folder, create a folder called namespace mapping,
Create a new file nsmappings.properties, and click OK.
2. Determine the name spaces defined by the Web service. Open the service
WSDL file, ITSOMartESB.MartJ2CBeanImplInboundServiceService.wsdl,
428 Patterns: Implementing Self-Service in an SOA Environment
and examine the namespace definitions defined in the <definitions> tag, as
in Example 12-13.
Example 12-13 Definitions attribute of a service WSDL file
<wsdl:definitions xmlns:impl="http://jcaService.patterns.ibm.com"
xmlns:intf="http://jcaService.patterns.ibm.com"
xmlns:sibusbinding="http://www.ibm.com/websphere/sib/webservices/IBM-PKHOODNode03Cell/ITSOMartE
SB/MartJ2CBeanImplInboundService/Binding" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsi="http://ws-i.org/profiles/basic/1.1/xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.ibm.com/websphere/sib/webservices/IBM-PKHOODNode03Cell/ITSOMartESB/
Service">
3. From this file we can determine the value of the targetNamespace is:
http://www.ibm.com/websphere/sib/webservices/IBM-PKHOODNode03Cell/ITSOMartE
SB/Service
We can also determine the value of the sibusbinding namespace is:
http://www.ibm.com/websphere/sib/webservices/IBM-PKHOODNode03Cell/ITSOMartE
SB/MartJ2CBeanImplInboundService/Binding
Notice that these name spaces incorporate the cell and name of the service
integration bus used.
4. Create a namespace mapping file to map these two name spaces to the Java
package com.ibm.patterns.jcaService. Perform the following:
We used the mappings shown in Example 12-14.
Example 12-14 Namespace mapping file
http\://www.ibm.com/websphere/sib/webservices/IBM-PKHOODNode03Cell/ITSOMartESB/Service=com.ibm.
patterns.jcaService
http\://www.ibm.com/websphere/sib/webservices/IBM-PKHOODNode03Cell/ITSOMartESB/MartJ2CBeanImplI
nboundService/Binding=com.ibm.patterns.jcaService
5. Save the changes to nsmapping.properties.
Generate Web service client
We are now ready to generate a Web service client for the JCA service. The
input for this is the imported WSDL file. More information about generating Web
service clients can be found in 10.5.2, “Creating a Web service from a session
bean” on page 305.
1. Select File New Other. Then select Web Services Web Service
Client and click Next.

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.