. 74
( 87 .)


groups and the development involves different tools. Speci¬cally, portlet
development can be done in any WebSphere Studio environment that has
the portlet toolkit installed while the code interfacing with the external
application”(sometimes called an enterprise information system (EIS))”
is best done within WebSphere Studio Application Developer Integration
Edition (WSADIE). Because we have already discussed portlet development
and the portlet toolkit in Chapters 14 through 19, the focus in this section
will be on the back-end integration aspects and using WSADIE.

JCA Resource Adapters
While there are many adapters for enterprise systems that can be used, J2EE
de¬nes a standard architecture for building adapters: the J2EE Connector
Architecture (JCA). The JCA standard provides a mechanism to store and
retrieve enterprise data in J2EE and is akin to the standardization provided
by JDBC to access relational databases. JCA is relatively new in the J2EE
landscape and has already been highly successful in making enterprise
integration easier to accomplish.
In order to use JCA you must have a JCA resource adapter. A JCA adapter
is speci¬c to an EIS (for example, SAP or PeopleSoft) and is contained in
a resource adapter archive (RAR) ¬le composed of the jar ¬les and native
libraries necessary to deploy the resource adapter on a J2EE container. JCA
adapters interact with a J2EE server and manage things such as connections,
transactions, and security. Connection management includes establishing,
pooling, and tearing down connections, allowing listeners registered with a
connection to receive events, and so on. The underlying protocol an adapter
uses to connect to an EIS is outside the scope of the JCA speci¬cation.
WY009-23 WY009-BenNatan-v1.cls May 11, 2004 14:53

444 Chapter 23

Transaction management includes support for both distributed transactions
providing a mechanism to propagate transactions that originate from inside
an application server to an EIS system as well as local transactions existing
only on a particular EIS resource. Finally, security allows the application
server to connect to an EIS system using security properties de¬ned either
at deployment time or at runtime.
JCA resource adapters are available for major packaged applications.
As an example, we will continue the discussion of this integration pattern
while using the WebSphere Adapter for mySAP.com to connect to a SAP
R/3 system. At the time of writing this chapter, this adapter supported SAP
R/3 release 3.1H and higher, 4.0B and higher, 4.5A and higher, and 4.6A,
4.6B, and 4.6C. In addition, you should download the WebSphere Adapter
for mySAP.com from the IBM Web site; there is no charge involved.
The JCA adapter for SAP provides a standards-based connection architec-
ture for interfacing with SAP systems”and speci¬cally, access to Remote
Function Call (RFCs) and Business Application Programming Interfaces
(BAPIs). RFC is the protocol used by SAP for remote communication, that
is, for communications between two independent SAP systems or for com-
munications between an SAP system and a non-SAP system. Programs
using RFCs can either make or receive RFC to or from an SAP system. SAP
R/3 systems contain a set of business objects, which are an object-oriented
representation of real-world business objects. Examples of business objects
are a purchase requisition, a G/L account, or an employee. BAPIs provide
a programming interface to such business objects and can be accessed from
Java programs using the JCO Java library provided by SAP.

WebSphere Adapter for mySAP.com and WSADIE
WebSphere Studio Application Developer Integration Edition, as its name
suggests, packages a large number of tools for helping you with integration
tasks. Once you install the WebSphere Adapter for mySAP.com, you can
browse BAPIs and RFCs from the SAP Business Object Repository and cre-
ate Web Service De¬nition Language (WSDL) representations of the desired
function modules. You can then use the WSDL representations to generate
Java proxies for BAPIs/RFCs both as Java beans and stateless session EJBs.
These beans can be used by your portlets.
Given that you have downloaded the WebSphere Adapter for mySAP.com
from the IBM Web site and that you have a working version of an SAP
R/3 system, the next thing to do is install the adapter into the appropriate
WebSphere Studio environment”in this case into WSADIE. This is impor-
tant because the JCA adapter not only provides a runtime environment for
making the calls to SAP but also includes a tool plugin, which will make
using the adapter much easier. Installing the mySAP.com adapter involves
WY009-23 WY009-BenNatan-v1.cls May 11, 2004 14:53

Integrating ExternalApplications withWebSphere Portal 445

running the installation ¬le and then performing the following procedure
within WSADIE:

1. Select Import from the File menu.
2. Select RAR ¬le and click Next.
3. Specify the location of the WebSphere Adapter for mySAP.com RAR
4. Check the Standalone connector project box and specify a project
5. Click Finish to import the resource adapter.
6. Open the Server Con¬guration perspective.
7. Create a server instance and a server con¬guration (EE Test
8. Expand Server Con¬gurations in the Server Con¬guration view.
9. Double-click your server con¬guration.
10. Click the J2C tab and click Add beside the J2C Resource Adapters
list in the server settings.
11. Select the name of your resource adapter (speci¬ed in step 6) from
the Resource Adapter Name drop-down list. Click OK.
12. Click Add beside the J2C Connection Factories pane. On the Create
Connection Factory window enter a name, a JNDI name for the
connection factory. Click OK.
13. In the Resource Properties pane enter the SAP R/3 connection
14. Close the editor and click Yes to save the changes.
15. Make sure to add the following entry to the PATH environment

If the PATH environment did not include this segment then you will
have to exit WSADIE and restart it for the changes to take effect.

Your server con¬guration should look similar to that shown in Figure
23-3. Having ¬nished the installation, you can start using the JCA Tool Plu-
gin to connect to SAP, ¬nd the proper BAPIs, build WSDL ¬les to describe
the APIs, and generate proxy beans for making the call from your portlets.
The JCA Tool Plugin makes use of WSDL to describe an EIS-speci¬c bind-
ing and to automatically generate a WSDL de¬nition from the metadata
WY009-23 WY009-BenNatan-v1.cls May 11, 2004 14:53

446 Chapter 23

Figure 23-3 Server con¬guration within WSADIE”node settings.

exposed by the EIS as well as automatically generate a proxy based on
this WSDL. This allows you to decouple yourself from the actual EIS and
think of the APIs available through the adapter as being similar to Web
services”at least in terms of the way they are described.

Describing the Interface Using WSDL
WSDL is perfectly suitable for describing any service (in fact, it is easier
to think of it without the “W™”i.e. as Service De¬nition Language). The
authors of the JCA Tool Plugin recognized this fact and made use of WSDL
to describe which services are offered by a speci¬c EIS instance and how
to access them. Figure 23-4 shows the mapping between WSDL constructs
and JCA constructs. The service created by the JCA Tool Plugin (described
by the WSDL document) is called an SAP service.

Generating the SAP Service and Using an SAP Proxy
To generate an SAP service you need to follow the steps given below:
1. Open the Service Project wizard by selecting File ➪ New ➪ Project.
WY009-23 WY009-BenNatan-v1.cls May 11, 2004 14:53

Integrating ExternalApplications withWebSphere Portal 447

Figure 23-4 Mapping WSDL constructs to JCA constructs.

2. Select Business Integration from the left pane and Service Project
from the right pane. Click Next.
3. Enter the project name and click Finish.
4. The Service Provider browser opens with a list of available service
providers. Select SAP Services. The Connection Properties page
5. In the “SAP Import” dialog, specify the necessary SAP R/3
connection properties for your SAP instance. For a system without
load balancing, the required properties are: hostName, systemNo,
client, userId, and language. Click Continue.
6. In the following page, specify a query string to list the desired
BAPIs/RFCs or type in a — for a catch-all query. Click the List Port
Types button to establish a connection with the SAL R/3 system and
query the available BAPIs/RFCs that match the query string.
7. Select the BAPIs/RFCs for which you want to generate the service
de¬nitions by checking the BAPIs/RFCs you want to use. Then click
the Add Service button.
WY009-23 WY009-BenNatan-v1.cls May 11, 2004 14:53

448 Chapter 23

8. Accept the default values and click the Finish button; this generates
the WSDL representation.
9. Switch back to the Service Provider browser and repeat steps 7 and 8
for each BAPI and RFC you require. The wizard will create two
WSDL ¬les for each BAPI/RFC.
WSADIE creates a service interface ¬le, a service binding ¬le, and a
schema de¬nition ¬le, all very similar to those generated for a Web ser-
vice. (See www-106.ibm.com/developerworks/views/webservices/
tutorials.jsp for a list of tutorials on Web services and WebSphere Stu-
dio.) In addition, WSADIE creates a .ser ¬le with serialized information
about the SAP R/3 instance. Note that while there is a service ¬le and a
binding ¬le per BAPI/RFC, there is only a single schema ¬le common to all.
Once you have the WSDL de¬nitions, you can use the service binding
¬le to generate a proxy bean called an SAP proxy by invoking the Service
Proxy wizard:
1. Right-click on one of the service binding ¬les and select New ➪ Proxy.
2. Click Next on the ¬rst page of the wizard. On the second page of the
wizard, select the Command bean option and check the BAPI/RFC.
Click Finish to generate the proxy.
3. Repeat steps 1 and 2 for every BAPI/RFC for which you want to
generate a proxy.
You can then use the proxy from your portlet code to get access to data
from the SAP system. In a runtime environment (after packaging your code
and deploying it on an instance of WP/WAS), this will look like Figure 23-5.
If you want to create a stateless session EJB as a wrapper to the BAPI/RFC,
make sure you have already created an Enterprise Application project and
within this project do the following:
1. Right-click the service binding ¬le for the BAPI/RFC and select
New ➪ Deployment.
2. The WSDL, service, and port type will be ¬lled in from the values
stored in the service binding ¬le. Make sure that the EAR, EJB, and
Web project values are correct. If you wish to enable the proxy
function as a Web service (perhaps to be used later by a remote
portlet), select SOAP as the incoming binding type. Click Next.
3. Click Next on the next wizard page leaving the JNDI name as
default. Specify the SOAP binding properties and click Next. Specify
the SOAP port address and click Finish.
4. By following these steps you have created both an EJB binding ¬le
and a SOAP binding ¬le. The deployment descriptor for the EJB
WY009-23 WY009-BenNatan-v1.cls May 11, 2004 14:53

Integrating ExternalApplications withWebSphere Portal 449

Figure 23-5 Generating and using the SAP proxy.

references the SAP connection factory. In order to bind this resource
reference to a physical connection factory, click the J2EE View tab and
expand EJB Modules, then right-click EJB and select Open with =>
EJB Extension Editor. Click the Bindings tab, expand the EJB entry
and the service entry, and select ResourceRef.
5. Enter the JNDI name you selected when con¬guring your
environment (for example, eis/SAP). Save your changes; you can
now use not only the proxy from your portlet but also the session
bean and a SOAP interface from local or remote portlets.

Developing Portlets Using EAI Connectors
Using EAI adapters to connect to external applications is similar to using
JCA adapters in that you can view the integration project as comprising
two development tasks: developing the code that makes the call using
the adapters and developing the portlets that generate the user interface
making use of the data and functions exposed through the adapters. The
WY009-23 WY009-BenNatan-v1.cls May 11, 2004 14:53


. 74
( 87 .)