Mastering SAP NetWeaver XI—Programming

14
www.sap-press.com 1 Mastering SAP NetWeaver ® XI—Programming Marcus Banner, Halil-Cem Gürsoy, Heinzpeter Klein Contents Introduction ................................................ 3 Content of This Book ............................ 4 Acknowledgments ................................ 4 1 Architecture of SAP NetWeaver Exchange Infrastructure ......................... 5 1.1 SAP NetWeaver .................................... 5 1.2 Process Integration Using SAP NetWeaver XI ................................ 6 1.3 Architecture of SAP NetWeaver XI ...... 6 1.4 SAP NetWeaver XI Landscape Topology ............................................... 7 2 SAP NetWeaver Development Infrastructure—Basic Principles .......... 9 2.1 Architecture of the SAP NetWeaver Development Infrastructure ................. 9 Design of NWDI ................................... 10 Components of NWDI ......................... 11 Component Model ............................... 12 Development Process in SAP NetWeaver Developer Studio .................................. 13 2.2 Tips for Installing SAP NetWeaver Developer Studio .................................. 13 2.3 Environment for Adapter Develop- ment ..................................................... 15 Eclipse ................................................... 15 Subversion ........................................... 16 Subclipse ............................................... 16 Apache Ant ........................................... 16 Java Development Kit ........................... 17 3 Programming Mappings in SAP NetWeaver XI .................................... 19 3.1 ABAP Mapping ..................................... 19 Scenario to Be Mapped ........................ 19 Activating the ABAP Mapping Function in SAP NetWeaver XI ............................ 21 Creating an ABAP Mapping Class ......... 23 ABAP Mapping Using the iXML Library ... 24 Integrating the ABAP Mapping in the XI Repository ........................................ 27 Customizing the XI Directory ............... 29 3.2 Java Mapping ........................................ 33 Implementing the Java Mapping Class ...................................................... 33 Testing the Mapping Class .................... 37 3.3 Graphical Mapping Editor .................... 39 4 Developing an Adapter .......................... 45 4.1 Theoretical Basics .................................. 45 XI Adapter Framework ......................... 45 J2EE Connector Architecture ............... 46 Special Features of SAP NetWeaver XI ... 47 4.2 Preparing the Partner Connectivity Kit ... 48 User Permissions ................................... 48 aii.properties ......................................... 49 Enabling the CPA Cache ....................... 49 Adaptations in the XI Adapter .............. 50 4.3 Preparing the Development Environ- ment ..................................................... 50 Integrating XI Libraries ......................... 51 Integrating Muse Libraries in Eclipse .... 51 Jabber Server and Client ....................... 52 Apache Ant ........................................... 53

Transcript of Mastering SAP NetWeaver XI—Programming

www.sap-press.com 1

Mastering SAP NetWeaver® XI—Programming

Marcus Banner, Halil-Cem Gürsoy, Heinzpeter Klein

Contents

Introduction ................................................ 3

Content of This Book ............................ 4

Acknowledgments ................................ 4

1 Architecture of SAP NetWeaver Exchange Infrastructure ......................... 5

1.1 SAP NetWeaver .................................... 5

1.2 Process Integration Using

SAP NetWeaver XI ................................ 6

1.3 Architecture of SAP NetWeaver XI ...... 6

1.4 SAP NetWeaver XI Landscape

Topology ............................................... 7

2 SAP NetWeaver Development Infrastructure—Basic Principles .......... 9

2.1 Architecture of the SAP NetWeaver

Development Infrastructure ................. 9

Design of NWDI ................................... 10

Components of NWDI ......................... 11

Component Model ............................... 12

Development Process in SAP NetWeaver

Developer Studio .................................. 13

2.2 Tips for Installing SAP NetWeaver

Developer Studio .................................. 13

2.3 Environment for Adapter Develop-

ment ..................................................... 15

Eclipse ................................................... 15

Subversion ........................................... 16

Subclipse ............................................... 16

Apache Ant ........................................... 16

Java Development Kit ........................... 17

3 Programming Mappings in SAP NetWeaver XI .................................... 19

3.1 ABAP Mapping ..................................... 19

Scenario to Be Mapped ........................ 19

Activating the ABAP Mapping Function

in SAP NetWeaver XI ............................ 21

Creating an ABAP Mapping Class ......... 23

ABAP Mapping Using the iXML Library ... 24

Integrating the ABAP Mapping in the

XI Repository ........................................ 27

Customizing the XI Directory ............... 29

3.2 Java Mapping ........................................ 33

Implementing the Java Mapping

Class ...................................................... 33

Testing the Mapping Class .................... 37

3.3 Graphical Mapping Editor .................... 39

4 Developing an Adapter .......................... 45

4.1 Theoretical Basics .................................. 45

XI Adapter Framework ......................... 45

J2EE Connector Architecture ............... 46

Special Features of SAP NetWeaver XI ... 47

4.2 Preparing the Partner Connectivity Kit ... 48

User Permissions ................................... 48

aii.properties ......................................... 49

Enabling the CPA Cache ....................... 49

Adaptations in the XI Adapter .............. 50

4.3 Preparing the Development Environ-

ment ..................................................... 50

Integrating XI Libraries ......................... 51

Integrating Muse Libraries in Eclipse .... 51

Jabber Server and Client ....................... 52

Apache Ant ........................................... 53

2 © Galileo Press 2007. All rights reserved.

Contents

Ant Task for SDA Creation .................... 53

Remote Deployment Using the

SDM API ............................................... 53

4.4 Deployment of the Muse Libraries in

SAP NetWeaver AS ............................... 54

4.5 Creating a New Eclipse Project ............ 56

4.6 Versioning the Project .......................... 58

4.7 Adapter Skeleton of SAP ...................... 59

4.8 Refactoring of Source Code and

Descriptors ............................................ 60

4.9 Implementing Jabber

Communication .................................... 61

4.10 Integration of Communication in

the Adapter ........................................... 69

Implementation of javax.resource.cci.

Connection Factory ............................... 70

ConnectionManager ............................. 71

ManagedConnectionFactory ................ 71

ManagedConnection ............................ 73

Connection Object ............................... 75

Interaction ............................................ 75

More Adaptations to the

Source Files ........................................... 76

4.11 Deployment Descriptors ...................... 76

connector-j2ee-engine.xml .................. 76

log-confi guration.xml (RAR) ................. 77

ra.xml .................................................... 77

application.xml ..................................... 78

application-j2ee-engine.xml ................. 78

[Package Name]-dd.xml ....................... 79

log-confi guration.xml (SDA) ................. 80

CPA Cache Metafi le .............................. 80

4.12 Build and Deployment of the

Adapter ................................................. 81

4.13 Uploading CPA Cache Metadata .......... 82

4.14 Testing in the Partner Connectivity

Kit ......................................................... 83

4.15 Adapter Module ................................... 86

Implementation .................................... 86

Testing the Adapter Module ................. 89

Application Options of a Module ......... 90

5 SLD API ......................................................... 91

5.1 Confi guring the Java Integrated

Development Environment (IDE) ......... 91

5.2 Implementing the CIM Client .............. 93

5.3 Testing the CIM Client .......................... 94

6 Debugging XI Applications ................... 97

6.1 Debugging ABAP Components ............ 97

6.2 Debugging Java Components ............... 99

7 List of Abbreviations ............................... 103

Index .............................................................. 105

www.sap-press.com 3

Introduction

This SAP PRESS Essentials guide, Mastering SAP

NetWeaver XI—Programming, is intended to complement

and enhance the topics that were not discussed in further

detail in the book Mastering SAP XI—Administration,1

since that book focused on other areas. This Essentials

guide can be regarded both as a practical guide to pro-

gramming and as an ideal addition to the aforementioned

book. This time, our focus is on development. As in the

practical guide for administration, we will make extensive

use of a real-life example that you can reproduce yourself

with relatively little effort in a minimal installation.

For developers, a minimal installation consists of SAP

NetWeaver Developer Studio (NWDS), which is based

on the development environment Eclipse; SAP Partner

Connectivity Kit (PCK) for the development of adapt-

ers; Subversion and Subclipse for version management2;

and Apache Ant as an indispensable aid that acts in the

background. For each of the development tools speci-

fi ed above, this book contains an extensive and com-

prehensible description of their functions as well as the

Web addresses you need to download the tools free of

charge.

The SAP PRESS Essentials guide Mastering SAP XI—

Administration was published in January 2006. At that

time, we explained in the foreword that, compared with

Version 2.0, SAP NetWeaver Exchange Infrastructure

(XI) 3.0 had been substantially improved and that with

increasing support package (SP) levels it would have the

potential of becoming a strong competitor to existing

Enterprise Application Integration (EAI) vendors. After a

year that saw some good (and not-so-good) SP updates,

our prediction proved to be true.

1 Marcus Banner and Heinzpeter Klein, Mastering SAP XI—Administration, SAP PRESS Essentials 11 (Bonn: Galileo Press, 2006).

2 Alternatively, you can also use Concurrent Versions System (CVS) or SAP Design Time Repository (DTR).

Today, SAP NetWeaver XI 3.0 with SP 16 is defi nitely a

product that must be considered as a serious competitor

to the established range of EAI products such as SeeBe-

yond, which recently was acquired by Sun Microsystems,

or IBM WebSphere.

And yet, larger companies that had already decided on

another EAI tool prior to the release of SAP NetWeaver

XI 3.0 are very reluctant to consider changing to SAP

NetWeaver XI. Here, concerns about asset and invest-

ment protection play a considerable role. For companies

that otherwise extensively employ SAP products, these

considerations often represent the biggest obstacle.

Meanwhile, from a technical point of view, these compa-

nies for the most part can fi nd no plausible reason against

the use of SAP NetWeaver XI 3.0 and in favor of using a

third-party software product in the EAI environment.

With this in mind, our intent in this book is to provide

you with some valuable tips and tricks along the way for

development in SAP NetWeaver XI.

One of the focuses of this book is on developing your

own XI adapters. Because the documentation that is offi -

cially (and unoffi cially) available for this topic is very lim-

ited and insuffi cient, one of our primary concerns was to

integrate this subject in this book. Our own experience

has shown that many SAP consultants who deal with SAP

NetWeaver XI and even want to do their own develop-

ment with it originally have come from an ABAP envi-

ronment. Because of this, they often encounter prob-

lems when working in the Java world and when using its

development environments and tools. We have tried to

take these issues into account and to formulate examples

in such a way that anyone with a basic knowledge of Java

can understand them. Readers who are experienced Java

developers should skip the rather comprehensive descrip-

tions of processes in the development environments and

4 © Galileo Press 2007. All rights reserved.

Introduction

also the Java code, which has deliberately been kept as

simple as possible.

We hope that this book inspires the development of

some new XI adapters and that we will soon have the

pleasure of meeting some developers on the Web! You

can download the source code for the sample adapter

from the websites that accompany this book: www.sap-

press.com and www.sap-hefte.de/1478.

Content of This Book

This book describes the basic principles of structuring and

performing the development of SAP adapters using Java

as well as different options for mapping and debugging.

Chapter 1 provides a brief and concise description of

SAP NetWeaver XI, while Chapter 2 deals with the archi-

tecture and infrastructure of SAP NetWeaver Develop-

ment Infrastructure (NWDI). In addition, Chapter 2 also

describes the SAP client installation for SAP NetWeaver

Developer Studio (NWDS). At this stage, we kept the

descriptions of Change Management Services (CMS)

and the Design Time Repository (DTR) relatively short,

as we used different development tools. These tools

comply with standard SAP requirements. Nevertheless,

we didn‘t want to completely deprive you of the inte-

grated SAP solution with CMS and DTR. Chapter 2 closes

with a detailed description of the set of tools used in the

adapter development environment (Eclipse, Subclipse,

Apache Ant, Java Development Kit).

After this discussion of basic principles, Chapter 3

deals with XI mapping for ABAP and for Java. These two

options are comprehensively described using numerous

real-life examples.

Chapter 4 focuses on how you can develop an adapter

using the PCK. In this chapter we provide you with a

description of the most common problems that can

occur during development, offer possible solutions, and

delve deeply into functionality. For those of you who

are experienced ABAP and Java developers, it will take

only a short period of time to familiarize yourselves with

everything you need to be able to implement customer

requirements in your own applications.

Other special topics such as the System Landscape

Directory (SLD) application programming interface (API)

(integrating Java classes into the XI environment) and

debugging in SAP NetWeaver XI are described in detail in

Chapter 5 and Chapter 6.

Acknowledgments

Marcus Banner would like to thank his family for the

understanding they showed during the time this book

was being written: You both mean the world to me!

Heinzpeter Klein would like to express his thanks to

his friends and family for the tolerance and understand-

ing they showed during all those days and nights when

he was absent: They haven‘t seen me in a long time.

Dr. Halil-Cem Gürsoy would like to thank his family for

all their patience and support as well as say thanks to CDI

AG and its employees for their support by providing the

infrastructure and food for thought.

We, the authors, hope you will have a lot of fun read-

ing this book. Hopefully, the topics discussed in this book

will spare you much tedious trial and error.

48 © Galileo Press 2007. All rights reserved.

4 Developing an Adapter

deployment of a Resource Adapter Archive (RAR ) is sup-

ported, an Enterprise Application Archive (EAR ) is not—in

contrast to the JCA specifi cation. The reason for this is that

the JCA specifi cation in this case stipulates a bundling with

an application (that is also contained in the EAR), where

the adapter may only be visible to this application (see JCA

1.0, Section 10.2). In SAP NetWeaver XI, however, we do

not deploy any applications; that is, the application that

accesses the adapter is the AF. This would mean that in

such a case, the adapter would have to be deployed in an

EAR bundled with the AF. Instead, you can use the SAP-

specifi c format Software Delivery Archive (SDA ), which

apart from the RAR contains additional information about

the adapter. This SDA can then be deployed as usual via

the Software Deployment Manager (SDM). SAP recom-

mends this method, and we will use an SDA in our exam-

ple as well.

4.2 Preparing the Partner Connectivity Kit

After all this theory, we will now get practical and develop

our own adapter. We will not reinvent the wheel but

rather follow SAP’s recommendation and use the sam-

ple adapter, which is included in every installation of the

Partner Connectivity Kit (PCK), as a starting point and

modify it according to our needs.

The development will be performed using the PCK.

On the one hand, the PCK is used for integrating sys-

tem landscapes in XI without having to install a full SAP

NetWeaver XI on them (partner scenario). On the other

hand, it serves as a development environment for adapt-

ers. We therefore assume that you have access to an SAP

NetWeaver system with a PCK (we use Version 3.0 SP

14).

User Permissions

First, you must set up, or confi gure, the user roles for

adapter development in the J2EE server. Open the J2EE

Engine Visual Administrator . On Windows systems, you

will fi nd it under <j2eeDir>\admin, where <j2eeDir> is the

directory of the J2EE container (for example, C:\usr\sap\

J2E\JC00\j2ee).

As soon as you execute the go.bat batch fi le, Visual

Administrator starts and welcomes you with a login

prompt (see Figure 4.3).

Figure 4.3 Login Screen of the J2EE Engine Visual Administrator

After you have connected to the system, you can imme-

diately go to the user permission management area to

give the user who is to develop the adapters the neces-

sary permissions. In the left navigation menu, select Ser-

vices � Security Provider � Policy Confi gurations.

Then you can select the appropriate component in the

center area as well as the Security Roles tab to assign

your user the proper permissions (see Figure 4.4). Table

4.1 shows the permissions to be assigned.

Component Role

sap.com/com.sap.af.app*AdapterFramework

Xi_af_adapter_monitor

sap.com/com.sap.af.app*CPACache Xi_af_cpa_invalidate

sap.com/com.sap.af.app*CPACache Xi_af_cpa_monitor

sap.com/com.sap.af.app*CPACache Xi_af_cpa_schemaupload

sap.com/com.sap.af.ms.app*MessagingSystem

Xi_af_receive

sap.com/com.sap.af.soapadapter*XISOAPAdapter

Xi_adapter_soap_message

sap.com/com.sap.sap.xi.mdt*mdt display

sap.com/com.sap.sap.xi.mdt*mdt modify

sap.com/com.sap.sap.xi.mdt*mdt payload

sap.com/com.sap.sap.xi.pck*aii_ib_sbeans.jar

administer

sap.com/com.sap.sap.xi.pck*pck singlesignon

sap.com/com.sap.sap.xi.pck*pck support

Table 4.1 Roles to Be Assigned to the PCK User

If several persons are going to participate in the develop-

ment, it’s recommended that you fi rst create a user group

(e.g., SAP_XI_PCK_ADMIN) and assign the users to this

group. After that, it’s completely fi ne to assign the per-

www.sap-press.com 49

missions to the group. Don’t close the application yet:

You will need the administration interface again as we

proceed further.

More details regarding the required rights can be

found in the SAP Notes 746328 and 792456.

aii.properties

Now you need to create the fi le aii.properties and copy it

to the <serverDir> directory. <serverDir> can be the direc-

tory /usr/sap/J2E/JC00/j2ee/cluster/server0, for example.

Listing 4.1 shows an example. Note that you need to

adapt the computer name and the ports.

Enabling the CPA Cache

Now you need to enable the CPA cache. This is done

using the J2EE Engine Visual Administrator. In the Admin-

istrator, go to the SAP XI AF CPA Cache service and adapt

the parameters as shown in Table 4.2.

Figure 4.4 Confi guration of the Roles for the PCK User via the J2EE Engine Visual Administrator

com.sap.aii.ib.client.properties = com.sap.aii.ib.client.*,com.sap.aii.connect.*,com.sap.aii.

ib.server.*,com.sap.aii.docu.*,com.sap.aii.pck.*### Connectionscom.sap.aii.connect.directory.contextroot = pckcom.sap.aii.connect.directory.name = was-xp-hguvm1com.sap.aii.connect.directory.httpport = 50000com.sap.aii.connect.directory.rmiport = 50004### Appl namecom.sap.aii.ib.client.applicationname.directory = sap.com/com.sap.xi.pck/com.sap.aii.ib.client.login.languages = EN,DE

Listing 4.1 Example of the aii.properties File (cont.)

4.2 Preparing the Partner Connectivity Kit

50 © Galileo Press 2007. All rights reserved.

4 Developing an Adapter

Parameters Value

cacheType PCK

SLDAccess False

Table 4.2 Enabling the CPA Cache

Figure 4.5 shows the changes of the parameters for the

CPA cache. Changes to the default settings are presented

in italics.

Adaptations in the XI Adapter

Some parameters in the confi guration of the XI adapter

must be adjusted as well. As described previously, go to

the J2EE Engine Visual Administrator and select the SAP

XI Adapter XI service. Adjust the parameters as shown in

Table 4.3.

Parameters Value

xiadapter.internal devModePCK

xiadapter.isconfig.url http://[Server name]:[J2EE Engine Port]/MessagingSystem/receive/AFW/XI

xiadapter.isconfig.user [User Name]

xiadapter.isconfig.password

[User Password]

Table 4.3 Adjusting the XI Adapter Parameters

4.3 Preparing the Development Environment

The components we suggest for developing an adapter

have already been described in detail in Section 2.3. We

assume that you have installed a Java Development Kit

### No locking for PCKcom.sap.aii.ib.server.lockauth.activation = falsecom.sap.aii.pck.server.compiler. classpath_resolverServiceName = classpath_resolvercom.sap.aii.docu.url = http://was-xp-hguvm1:50000/pck/docOnline/DOCUcom.sap.aii.docu.languages = EN,DE

Listing 4.1 Example of the aii.properties File (cont.)

Figure 4.5 Changes to the Parameters for the CPA Cache

www.sap-press.com 51

(JDK) as well as Eclipse on your development system. To

be on the safe side (e.g., in order to be able to access an

older version), you should also use a versioning system.

Integrating XI Libraries

The following Java libraries (JAR fi les) are required for

developing an adapter. Depending on your needs, there

might be more:

<serverDir>/bin/ext/com.sap.aii.af.lib/aii_af_trace.jar

<serverDir>/bin/ext/com.sap.aii.af.lib/aii_af_cci.jar

<serverDir>/bin/ext/com.sap.aii.af.lib/aii_af_mp.jar

<serverDir>/bin/ext/com.sap.aii.af.lib/aii_af_ms_api.jar

<serverDir>/bin/ext/com.sap.aii.af.lib/aii_af_ms_spi.jar

<serverDir>/bin/ext/com.sap.aii.util.misc/aii_util_misc.

jar

<serverDir>/bin/ext/com.sap.xi.util.misc/aii_utilxi_misc.

jar

<serverDir>/bin/ext/j2eeca/connector.jar

<serverDir>/bin/ext/com.sap.guid/guidgenerator.jar

<serverDir>/bin/services/com.sap.aii.adapter.xi.svc/aii_

adapter_xi_svc.jar

<serverDir>/bin/services/com.sap.aii.af.cpa.svc/aii_af_

cpa.jar

<serverDir>/bin/services/com.sap.aii.af.svc/aii_af_svc.

jar

all J2EE client libraries under <j2eeDir>/j2eeclient

These libraries must later be communicated to your

adapter project in Eclipse. To make your life easier, it is

recommended that you thematically bundle the libraries

under Eclipse in order to be able to completely assign

them to a project via a few mouse clicks. In Eclipse, open

the Windows � Preferences menu, and in the left navi-

gation pane, select the Java � Build Path � User Libraries

entry (see Figure 4.6). By clicking on New you are pre-

sented with a dialog where you can enter the name of the

user library, in our case SAPXIAF, for the XI-AF-JAR fi les

as well as SAPJ2EECLIENT for the J2EE client libraries. If

you created these user libraries (which are empty at fi rst),

you can select them and then add JAR fi les via the Add

JARs button. Add the fi les listed above. These user librar-

ies can now be exposed to any project in your devel-

opment environment; otherwise, you would have to go

through a similar procedure for every adapter project.

Integrating Muse Libraries in Eclipse

To be able to send messages to a Jabber server via the

adapter, we need a library that implements the Jabber/

XMPP protocol. We recommend the Muse library, which

is fairly popular and stable (http://open.echomine.org/

confl uence/display/MUSE/Muse+Home).

Figure 4.6 Bundling JAR Files to User Libraries

4.3 Preparing the Development Environment

52 © Galileo Press 2007. All rights reserved.

4 Developing an Adapter

Download the current version from the Muse home page;

we used Version 0.81 for this book. Unzip the down-

loaded ZIP fi le to an appropriate folder.

Then integrate the required muse.jar fi le in a user

library in Eclipse, as described above.

Jabber Server and Client

In addition to the Muse libraries, we also need a Jabber

server and a Jabber client. There is a very large selection

of both commercial and free products. A comprehensive

overview can be found at www.jabber.org.

As a server, we recommend Wildfi re by Jive Soft-

ware , which is licensed under the GNU Public License

(see www.gnu.org/copyleft/gpl.html). You can download

Wildfi re from the Jive home page (www.jivesoftware.org/

wildfi re/). We used Version 2.6.1 for our scenario. Install

Wildfi re by following the simple instructions in the docu-

mentation. After you have started Wildfi re for the fi rst

time, you should go to the administration interface (which

can be found by default at http://127.0.0.1:9090/) and

set up two users. In the administration interface, select

Users/Groups in the upper navigation and then Create

New User in the left pane (see Figure 4.7). These users

will be used for sending or receiving messages from the

adapter.

To make sure that messages to a currently offl ine user

do not get lost, it is recommended you have them saved

by the server so that they can be delivered to the receiver

when he or she logs back in (offl ine messages). To do this,

under Server � Server Settings � Offl ine Messages, select

the Store and Always Store options.

As a Jabber client, we recommend Ψ (Psi ), which can

be found at http://psi-im.org/. Ψ is available not only for

Windows but also for many other platforms. After you’ve

downloaded Ψ, the installation is fairly simple: Just start

the installer and follow the specifi ed steps.

After you start Ψ for the fi rst time, you need to set

up your users. First, a profi le is set up that can accom-

modate several users. After the profi le has been created,

you set up the Jabber accounts. To do this, use the two

users you just set up in the Wildfi re server. Note that

you need to attach “@[ServerName]” to the user name

to inform the client on which server the users are to be

found. Last, these users must be exposed to each other as

contacts. During this process, authorization messages are

exchanged. This procedure can be handled intuitively.

After these steps have been completed, your Ψ could

look like the one shown in Figure 4.8. The Jabber client

Ψ is active with two accounts, and the contacts are online

as well.

Figure 4.7 Setting Up New Users via the Wildfi re Administration Interface

www.sap-press.com 53

Figure 4.8 Active Jabber Client Ψ with Two Accounts

As an alternative to your own Jabber server, you could

also use publicly accessible servers (a list can be found

at www.xmpp.net/) and set up your users there. For our

scenario, however, this possibly requires the confi gura-

tion of fi rewalls in your domain to enable communica-

tion. However, you can also use an HTTP proxy with Ψ.

Additionally, you can use any Jabber client instead of Ψ.

You will fi nd an overview of clients at www.jabber.org.

Apache Ant

We will use the free tool Apache Ant (see Chapter 3) to

compile the source codes, assemble the archive fi les, and

implement the deployment.

Download the most recent stable Ant release from the

Ant home page (http://ant.apache.org) under Download �

Binary Distributions. Currently, this is Version 1.6.5, but

our project is compatible with any Ant 1.6 version. Once

you have unzipped the ZIP archive to a folder, custom-

ize some system environment variables in Windows XP

or 2000.

To adjust an environment variable in Windows 2000

or XP, go to Control Panel, select System, click on the

Advanced tab, and then select the Environment Vari-

ables button. By clicking on New under System Vari-

ables, you fi rst create the environment variable ANT_HOME

(see Figure 4.9).

Figure 4.9 Creating a System Environment Variable in Windows XP and 2000

Now perform the same steps to adjust the system envi-

ronment variable Path to include the Ant bin directory in

the search path. You can use the ANT_HOME environment

variable you set previously: Just add “%ANT_HOME%\bin”

to the end of the existing defi nition.

You should now be able to start Ant. Verify this by

opening a Windows command prompt (Start Run, and

then enter “cmd”) and entering “ant –version”. The out-

put should then appear as follows:

C:\>ant -version

Apache Ant version 1.6.5 compiled on June 2

2005

C:\>

Ant Task for SDA Creation

To create SDAs without NetWeaver Developer Studio

(NWDS) or the J2EE Engine Deploy Tool, we need an Ant

task that can perform this for us. A solution already exists

in NWDS in the form of the JarSAP task.

You can fi nd the required JAR fi le, jar4sap.jar, in the

NWDS installation in the plug-in com.sap.ide.eclipse.jar-

sap, which can normally be found under C:\Programs\

SAP\JDT\eclipse\plugins\com.sap.ide.eclipse.jarsap\lib.

You will later enter the location of this fi le in the build

script for Ant.

Remote Deployment Using the SDM API

Because we want to deploy the required archives without

delay on the J2EE server after we’ve compiled and assem-

bled them, a deployment via the SDM interface would be

rather cumbersome. Since we are implementing Ant any-

way, there is an elegant solution: David Beisert , a well-

known consultant in the NetWeaver environment, intro-

duced an Ant task in his SDN blog that can be used to

deploy from Ant via the SDM API (https://weblogs.sdn.

sap.com/pub/wlg/3138).

Follow the link Download SDM Deployment Task

and download the ZIP fi le. Then rename the downloaded

sdmAnt.zip fi le to sdmAnt.jar.

Another important note regarding the SDM: If you

encounter problems during the deployment later on

in the project and obtain the message “Server <Server

name> did not accept login request as admin on port

<Server Port>,” please take note of SAP Note 941150.

In this case you’ll need to install a current version of the

4.3 Preparing the Development Environment

54 © Galileo Press 2007. All rights reserved.

4 Developing an Adapter

SDM, as the note recommends. Because a description

of an SDM installation would exceed the scope of this

book, please refer to SAP Note 860939, which discusses

an SDM installation, or an upgrade, in great detail.

4.4 Deployment of the Muse Libraries in SAP NetWeaver AS

Up to now, we’ve set up our development environment

and made development preparations within the PCK.

Over the course of this process, we exposed the Muse

libraries to our development environment. Because the

adapter will run in the PCK during the development phase

and later in a full SAP NetWeaver XI, we must deploy the

libraries required by our adapter in the J2EE container.

You already downloaded the Muse libraries and stored

them in a separate directory. We will now add some of

these libraries to a library project , wrap this library project

in an SDA, and deploy it on the J2EE container.

To do this, we’ll start the J2EE Engine Deploy Tool

(which can be found under <j2eeDir>/deploying) by click-

ing on the DeployTool.bat batch fi le.

As soon as the application is started, you can create

a new deployment project by clicking on Project � New

Project (see Figure 4.10). We recommend you set up a

separate directory by clicking on the Create New Direc-

tory icon (see Figure 4.11).

Figure 4.10 Creating a New Deployment Project

Once you have created a new directory for the project,

named the project (Address fi eld), and confi rmed every-

thing by clicking on OK, you can proceed. Now you

need to inform the Deploy Tool that you want to set up

a library. Go to the Server Components tab, in the menu

select the Server Components item, and in the pulldown

menu select the Add Library entry. An easier way of dis-

playing the window that now opens is to use the short-

cut Ctrl+L. Enter “Muse” as the name of the library, and

leave the other option as Create New. Then click again

on the Server Components menu option and on Create

Dispatcher. In the left area, an entry under Muse.jar and

SERVER is made automatically.

Figure 4.11 Create New Directory Icon

Now you can start entering the information for the

deployment. Click on SERVER, and enter the necessary

data as follows (see Figure 4.12): For the Provider Name,

select “com.echomine” (these libraries are, after all, from

Echomine), select “muse” for both Component Name

and Display Name, and for the version, enter the Muse

version you downloaded (in our example, 0.81). Use the

same procedure and data for the dispatcher.

Now you can add the required JAR fi les. Select the

Muse.jar entry. In the opening dialog, you can click on

the button to the right of the JAR fi eld to select the three

required fi les and add them to the list by clicking on the

Add button (see Figure 4.13). The following are the fi les:

commons-logging.jar (Apache Commons Logging)

jdom.jar (XML parser library)

muse.jar (the Muse application programming inter-

face—API)

Once you have selected and added the fi les, you should

see a picture similar to what Figure 4.13 shows.

www.sap-press.com 105

Index

AABAP/4 Debugger 97

ABAP/4 development environment 10

ABAP mapping 19, 97

Adapter engine 45

Adapter Framework 45, 69

Adapter Metadata Upload 82

Adapter module 86

Adapter skeleton 59

aii.properties 49

Ant 15, 16, 53, 81

call 81

Ant target 81

Ant task 53, 81

Apache Ant 16

application-j2ee-engine.xml 78, 88

application.xml 78

Audit log 85, 87

Audit messages 75

Automatic mapping 41

BBeisert 53

Branches 58

Breakpoint 97, 100

Build 81

Build script 81

Build tool 16

Byte code 17

CC# 9

C++ 9

Central information provider 7

Change history 61

Change Management Service (CMS) 12

Chatting 45

CIM client 93, 94, 95

CIM server 91

Class interfaces 24

Classloader 76, 85

Class names 77

com.echomine.jabber.Jabber 66

com.echomine.jabber.JabberContext 64

com.inqmy.lib.xml.StandardDOMWriter

36

com.sap.aii.af.monitor.api.AdapterMoni-

tor 71

com.sap.aii.af.mp.module.Module 86

com.sap.aii.af.mp.module.ModuleHome

87

com.sap.aii.af.mp.module.ModuleLo-

cal 87

com.sap.aii.af.mp.module.ModuleLocal-

Home 87

com.sap.aii.af.mp.module.ModuleRe-

mote 87

com.sap.aii.af.ra.cci.NWConnectionFac-

tory 70

com.sap.aii.af.service.auditlog.Audit 75

com.sap.aii.af.service.auditlog.AuditMes-

sageKey 75

com.sap.aii.af.service.trace.Trace 67

com.sap.aii.mapping.api.Streamtransfor-

mation 33

com.sap.aii.mapping.api.Streamtransfor-

mationConstant 34

com.sap.aii.mapping.api.StreamTransfor-

mationException 36

com.sap.engine.interfaces.connector.

ManagedConnectionFactoryActiva-

tion 71

com.sap.sdm.ant.JarSAP 81

Common Client Interface 46

Component Build Service 12

Component model 10, 12

Configuration interface 80

Connection management 47

Connection pooling 69, 71, 83

connector-j2ee-engine.xml 76, 78

Constructor definition 64

CPA cache 49, 73, 76

CPA cache metadata 82

CPA cache metafile 80

CVS 15, 16

DDatabase table 21

dd.xml 79

Debugging 97

Debugging in ABAP 97

Debugging in Java 99

Debugging mode 99

DeltaV 16

DeltaV specification 16

Deployment 53, 54, 81

Deployment descriptors 59, 60, 76

Deprecated 72

Design Time Repository (DTR) 11, 15, 16

Development Components (DC) 12

Development Objects (DO) 12

Direction OUTBOUND 76

DOM parser 34

EEclipse 15, 58

Eclipse Foundation Inc. 15

Eclipse project 34, 56

ejb-j2ee-engine.xml 87

EJB Module Project 86

Enterprise Application Archive 48, 78

Enterprise Application Project 88

Enterprise Java Bean (EJB) 86

Exchange Infrastructure landscape

topology 7

106 © Galileo Press 2007. All rights reserved.

Index

FFile adapter 83

GGNU Public License 52

Google 45

Google Talk 45

Gosling, James 9

Graphical Mapping Editor 39

Groovy 17

HHewlett-Packard 45

IInbound 80

Inbound processing 71

Inbox adapter 30

InputByteStream 34

Instant messaging system 45

Interaction 75

Interface mapping 28

iXML functions 24

iXML Library 24

JJ2EE 9, 15

J2EE application 56

J2EE Connector Architecture 45, 46

J2EE container 56

J2EE Engine Deploy Tool 54

J2EE Engine Visual Administrator 48

Jabber 45

Jabber client 52

Jabber communication 61

Jabber server 51, 52

JAR files 91

Java 9, 15

development environment 15

java.lang.ClassCastException 87

java.lang.Runnable 71

Java Community Process 46

Java Connector Architecture 9

Java debugger 99

Java Development Infrastructure (JDI) 15

Java Development Kit 57

Java Development Kit (JDK) 15, 17

Java IDE 91

Java interface 61

Java mapping 33

Java Naming and Directory Interface

(JNDI) 73, 80, 87, 89

Java Platform Debugger Architecture

(JDPA) 99

Java Specification Request 46

Java versions 9

Java Virtual Machine (JVM) 9

javax.resource.cci.Connection 47, 73,

74, 75

javax.resource.cci.ConnectionFactory 47,

69, 70

javax.resource.cci.ConnectionSpec 47

javax.resource.cci.Interaction 70, 75

javax.resource.ResourceException 64

javax.resource.spi.ConnectionEventLis-

tener 47

javax.resource.spi.ConnectionManager

69, 71

javax.resource.spi. LocalTransaction 47

javax.resource.spi.ManagedConnection

70, 71, 73

javax.resource.spi.ManagedConnection-

Factory 70, 71

JEE 9

Jive software 52

LLibrary project 54

LocalTransaction 47

log-configuration.xml 77, 80, 88

Logging category 76

Log manager 77

Loose coupling 12

Mmake 15, 16

makefile 16

ManagedConnection 47

Managed environment 47

Mapping class 34

Mapping routines 19

Mapping test 98

Metadata 76, 78

Microsoft 9

Module development 86

Muse libraries 51

NName Service 12

Namespace 76

Naming in Java 61

.Net 9

NetBeans 15

NoTransaction 47

OOpen source 15

Organize Imports 94

Outbound 80

Outbox adapter 31

PPackage Explorer 57, 63

Partner Connectivity Kit 45, 48, 83

Perforce 64

Programming mappings 19

Project versioning 58

Psi 52

Public parts 12

Rra.xml 59, 77

Receiver agreement 84

Receiver determination 31, 32

Refactoring 60, 77

Reference 78

Reference implementation 59

Registration of the monitoring interface

72

Remote deployment 53

Resource Adapter Archive 48

RFC destinations 20

SSample adapter 59

SampleRa.xml 59

SAP NetWeaver 5

SAP NetWeaver Developer Studio

(NWDS) 13

SAP NetWeaver Development Infrastruc-

ture (NWDI) 9, 11

SAP XML Toolkit 33

SAX parser 34

SDA 16

www.sap-press.com 107

Index

SDA creation 53

SDM 16

SDM administrator 55

SDM API 53

SDM GUI 55

SDM installation 54

SDM repository 56

SDN blog 53

Security Roles 48

Sender agreement 32, 84

Sender interface 34

Sequence diagram 70

Serialization 36

Server Provider Interface 47

Service Programming Interface 46

SIGNATURE 65

SLD API 91

Software component (SC) 12

Software Delivery Archive (SDA) 48

Software Deployment Manager (SDM)

48

Stateless Session Bean 86

Subclipse 15, 16, 58

substring 43

Subversion 15, 16, 58

Subversion Book 58

Sun 15

System contracts 47

System Landscape Directory (SLD) 12, 91

TTags 58

TCP/IP connection 20

TRACE 64

Trace 77

Transaction management 47

Trunk 58

UUser permissions 48

VVERSION_ID 64

Version management 16

Version management system 58

WWebDAV 16

Wildfire 52

XXI adapter 50

XI Adapter Framework (AF) 45

XI directory 29

XI libraries 51

XI repository 27

XMPP 45