290 Migrating from WebSphere Application Server Community Edition to WebSphere Application Server
4. Modify ejb-jar.xml to link the EJB to the Web service as highlighted in
Example 7-4.
Example 7-4 The ejb-jar.xml file
<session id="Session_LodgingPOEndpoint">
<description><![CDATA[An EJB named LodgingPOEndpoint]]></description>
<display-name>LodgingPOEndpointBean</display-name>
<ejb-name>LodgingPOEndpoint</ejb-name>
<service-endpoint>
com.sun.j2ee.blueprints.lodgingsupplier.powebservice.LodgingPOEndpo
int
</service-endpoint>
<ejb-class>
com.sun.j2ee.blueprints.lodgingsupplier.powebservice.LodgingPOEndpo
intSession </ejb-class>
After completing these steps, the LodgingPOEndpointBean Stateless Session
Bean is exposed as a Web service.
Generating a Web Service Client
To generate a client for the WebServiceBroker Web service, you need to obtain
its WSDL file. The WSDL file is in the OPC module of the Adventure Builder
application. You can import the WSDL file into the META-INF/wsdl directory of
the LodgingSupplier-EJB project in Eclipse.
You use the wscompile tool provided in the Sun JWSDP v2.0 to create the client
files required by WebSphere Application Server Community Edition V1.1.0.1.
The wscompile tool takes an XML configuration as input in which you specify the
path to the WSDL for the Web service for which you need to generate a client.
Example 7-5 shows this file.
Example 7-5 The webservicebroker-client-config.xml file
<?xml version="1.0" encoding="UTF-8"?>
<configuration
xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config">
<wsdl name="WebServiceBrokerClient"
location="file:wsdl/WebServiceBroker.wsdl"
packageName="com.sun.j2ee.blueprints.lodgingsupplier.pomessagebean">
<typeMappingRegistry />
</wsdl>
</configuration>
Chapter 7. Developing the application on WebSphere Application Server Community Edition 291
In this example, the location is the relative path of the WSDL file from the
directory where you are executing wscompile. For example, suppose you
execute wscompile in C:\Adventure. Then, the path of the WSDL file will be
C:\Adventure\wsdl\WebServiceBroker.wsdl.
Next, you need to invoke wscompile with the configuration file as shown in
Example 7-5.
Issue the following command:
wscompile -gen:client -s generated
configs\webservicebroker-client-config.xml -source 1.1 -keep
-mapping generated\webservicebroker-mapping.xml
In this command:
configs\webservicebroker-client-config.xml is the relative path to the
config file from the directory where you are executing wscompile.
generated\webservicebroker-mapping.xml is the location where the
JAX-RPC mapping file will be generated.
This command results in the client code created in the generated directory. The
generated directory is also relative to the directory where you are executing
wscompile. You need to create the regenerated command before calling the
wscompile command.
Next, you need to import the generated source files from Eclipse into the
com.sun.j2ee.blueprints.lodgingsupplier.pomessagebean package. Actually, you
need to import only two of those files, namely BrokerServiceIntf.java and
WebServiceBroker.java because WebSphere Application Server Community
Edition V1.1.0.1 uses dynamic proxies to invoke the Web service. You also need
to import the JAX-RPC mapping file into the META-INF directory of the
LodgingSupplier-EJB project in Eclipse.
292 Migrating from WebSphere Application Server Community Edition to WebSphere Application Server
Adding the dependencies to the application
Finally, you need to add some dependencies to the geronimo-application.xml file,
as shown in Example 7-6.
Example 7-6 The geronimo-application.xml file
<application xmlns="http://geronimo.apache.org/xml/ns/j2ee/application-1.1">
<dep:environment xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.1">
<dep:moduleId>
<dep:groupId>adventure</dep:groupId>
<dep:artifactId>lodgingsupplier</dep:artifactId>
<dep:version>1.0</dep:version>
<dep:type>ear</dep:type>
</dep:moduleId>
<dep:dependencies>
<dep:dependency>
<dep:groupId>geronimo</dep:groupId>
<dep:artifactId>tomcat</dep:artifactId>
<dep:version>1.0</dep:version>
<dep:type>car</dep:type>
</dep:dependency>
<dep:dependency>
<dep:groupId>adventure</dep:groupId>
<dep:artifactId>AdventureDB</dep:artifactId>
<dep:version>1.0</dep:version>
<dep:type>rar</dep:type>
</dep:dependency>
<dep:dependency>
<dep:groupId>adventure</dep:groupId>
<dep:artifactId>lodging-jms</dep:artifactId>
<dep:version>1.0</dep:version>
<dep:type>rar</dep:type>
</dep:dependency>
</dep:dependencies>
<dep:hidden-classes />
<dep:non-overridable-classes />
</dep:environment>
</application>
Deploying the LodgingSupplier Module on the Server
To deploy the LodgingSupplier Module on the server, right-click the
LodgingSupplier project in Eclipse and export it as an EAR to a location of your
choice. In our example, we exported this EAR to
<adventure_src>\src\SG247433\build\lodgingsupplier.ear. Deploy this EAR from

Get Migrating from WebSphere Application Server Community Edition to WebSphere Application Server now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.