SAP NetWeaver PI - Using The Integration Directory API
SAP NetWeaver PI - Using The Integration Directory API
SAP NetWeaver PI - Using The Integration Directory API
Applies to:
EHP 1 for SAP NetWeaver Process Integration (PI) 7.1 and partly SAP NetWeaver PI 7.0, Integration
Directory Application Programming Interface (Directory API).
For more information, visit the Service Bus-based Integration homepage.
Summary
This paper provides an outline to the main aspects of the SAP NetWeaver Integration Directory API for
version EHP 1 for SAP NetWeaver PI 7.1 (shortly referred to as PI 7.11 in this article) and higher and
provides some hints on the differences to version SAP NetWeaver PI 7.0 (shortly referred to as PI 7.0).
Author Bio
Daniel Ritter is Software Developer at SAP NetWeaver PI.
Table of Contents
Preliminaries ....................................................................................................................................................... 3
Introduction / Overview ................................................................................................................................... 3
Prerequisite of using the Directory API ........................................................................................................... 3
Getting Started - Development Process ............................................................................................................. 4
Importing WSDL from Enterprise Services Repository ................................................................................... 4
Importing WSDL from Remote Location / File System ................................................................................... 6
Query and Read Configuration Content ............................................................................................................. 8
Web Service Client Configuration ................................................................................................................... 9
Integration Directory Data Access Object ....................................................................................................... 9
Query and Read Integration Directory .......................................................................................................... 11
Change Lists and Write PI Configuration Content ............................................................................................ 13
Using Change Lists ....................................................................................................................................... 13
Create PI Configuration Content ................................................................................................................... 14
Case Study: Create new Receiver with XI Adapter ...................................................................................... 14
Appendix ........................................................................................................................................................... 19
Related Content ................................................................................................................................................ 40
Copyright........................................................................................................................................................... 41
Preliminaries
Introduction / Overview
The SAP Netweaver Process Integration - Integration Directory (Builder) is the environment for configuring
the communication of the Integration Server and the Advanced Adapter Engine. The set of configuration
objects in the Integration Directory includes e.g. communication components (e.g. Business Systems from
SLD) for senders and receivers, logical routing (receiver determination, interface determination) as well as
technical routing (receiver agreement).
In addition to the Integration Builder, there is also a web service-based application programming interface
(API), which can be used to modify and activate objects in the Integration Directory. The API provides the
same configuration options that are possible in the Integration Directory and is implemented as synchronous
web services on the java server. Thus the web service WSDLs are available in the ES Repository (or
Integration Repository in the earlier version SAP NetWeaver PI 7.0) and from the java server’s web service
runtime.
In this document, the main focus will be on how to use the directory web service API in the PI 7.11 (and later
releases) environment, giving hints how particular parts of the implementation would look like with PI 7.0.
This new version of the Directory API is available with EHP 1 for SAP NetWeaver PI 7.1. When explaining
the API, the corresponding parts of the Integration Directory and possibly the ES Repository (respectively
Integration Repository) are set into context. However, a full comparison of the PI 7.0 and PI 7.11 (and later
releases) API and explanation of the PI tools is not in scope in this document. For a comprehensive overview
of the Integration Directory and API please refer to [1], [2]. When looking for a sample exclusively dealing
with Directory API 7.0 see [3].
Note: In general, when using SAP Netweaver PI 7.1 (and later releases), but working with the Directory API, version 7.0,
only those objects can be used, which do not use new features introduced later. For instance, trying to access
attributes of sender agreements, like software component version of sender interface with schema validation, will
lead to a version incompatibility exception.
The first part of the document (see Getting Started - Development Process) deals with the setup of the web
service client. This is the basis for the query and read implementation (see Query and Read Configuration
Content) as well as the change list administration and creation of configuration objects (see Change Lists
and Write PI Configuration Content) which is explained at a sample.
Figure 1: NWDS import wizard showing the selection of WSDL (under Web services), and the import
dialog with the list of available WSDL sources
Figure 2: NWDS preferences view showing the configuration of the Enterprise Service Browser
After logging into the system's Enterprise Services Repository via NWDS import wizard, it is possible to
browse through all services offered (see Figure 3) by Software Component Version and choose the service
for which a client has to be generated.
Figure 3: Import wizard using login to ES Repository showing all services available in the repository
grouped by software component version
Figure 4: Service definition view of the Single Service Administration in SAP NetWeaver
Administrator showing old (SAP NetWeaver 7.0) and new (SAP NetWeaver 7.11) services available in
the corresponding ES Repository with their qualified WSDL. Suffix -Vi indicates old (NW 7.0) API
services and suffix -In denotes new (>= NW 7.11) services
It can be loaded from the service definition using the WSDLs tab in the details section of a selected service
(see Figure 4). Within this file binding information is already included, to avoid additional configuration.
After a successful import of the WSDL from arbitrary location, the web service client can be created by
executing the
client generation on the file (see Figure 5, right-click on the file » Web Services » Generate Client).
Figure 5: NWDS web service client generation possibility when right-clicking on the imported WSDL
The generation wizard (see Figure 6) is the same that is used for direct web service client creation (right-click
on Project » New » Other » WebServices » Web Service Client and paste the WSDL URL from the remote
location section).
Figure 6: NWDS client generation wizard which is accessible via WSDL or directly via NWDS project
showing the configuration of the client to be created
Note: if no additional web service runtime is installed on the system, the SAP NetWeaver runtime can be used. However,
it is not set as default in the wizard and has to be set explicitly.
The generated web service client can now be used in any application within this NWDS project to call the
Integration Directory services in the specified SAP NetWeaver system. During the development it is very
helpful to use the Web Service Navigator for viewing the services and determining their obligatory
parameters as well as their keys.
Figure 7: Web Service Navigator view accessed by Provider System on local Java AS showing the
search result for configuration scenarios. Suffix -Vi indicates old (NW 7.0) API services and suffix -In
denotes new (>= NW 7.11) services
When starting with configuration scenarios, using "ConifgurationScenarioIn" web service (see Figure 7), all
configuration objects added to the scenario can be accessed. However, only key information is returned,
which requires additional direct calls to the single configuration objects. Hence this document shows how to
access the configurable objects within the standard PI configuration directly. More specifically sample access
to PI communication components (business components, business systems) and the technical routing
(sender/receiver agreements, sender/receiver channels) are described.
As described before, a new NWDS Java project is created called "PIDirectory_Article" with a src-package
"com.sap.pi.directory.article" containing the following classes:
DirectoryAPIMain: Main()
DirectoryApiDAO: data access object which encapsulates the complete access to the Integration
Directory
DirectoryApiConfiguration: Parameter settings for Integration Directory access
Then the required web service clients for communication components (BusinessSystemIn,
BusinessComponentIn) and technical routing (SenderAgreementIn, ReceiverAgreementIn,
CommunicationChannelIn) are created from their WSDLs as shown before. In Figure 8 the NWDS project
structure is denoted showing the manually created Java classes as well as the generated web service
clients.
Figure 8: NWDS project structure showing manually created Java classes as well as generated web
service clients
In this context (see Appendix, Listing 1), USERID and PASSWORD are the same that are used to access
Integration Directory. SERVER_NAME and SERVER_PORT specify the PI server and its HTTP port.
// get port
BusinessSystemIn systemComp = service.getBusinessSystemInPort();
Code snippet: call method to setup the context of the client port
The "setupContext" method is treating the port object as "BindingProvider", determines the endpoint address
property and sets USERID, PASSWORD and the ENDPOINT_ADDRESS to it. This is basically the same
mechanism as in the SAP NetWeaver PI 7.0 Directory API. The only difference apart from the different web
service clients and some types is the instantiation of the port object which is done as follows:
Code snippet: Integration Directory API 7.0 sample for retrieving the port
// get port
BusinessSystemInServiceVi systemComp = service.getHTTPBasicAuthPort();
Then a request object, e.g. for query, is created filled with relevant data (if necessary) and used as import
parameter when calling the service using the port object.
In case of a query, the result contains the keys of the found PI configuration objects as java.util.List of
CommunicationComponentID and a list of log messages in case an exception occurred during execution.
Note: The log message type is LogMessageCollection which contains java.util.List for all provided PI
configuration objects. However, when querying e.g. for business systems only
getLogMessageBusinessSystem() could contain exceptions which resulted from the query.
The keys of the configuration objects can then be used to read the PI configuration object data. Hence they
are added via addAll(ids) to the request object before execution.
Code snippet: create read object and add relevant information before executing
Code snippet: create read object and add relevant information before executing
An important parameter is ReadContextCode which specifies the change list settings {ACTIVE,USER} for
user specific or active change lists.
Code snippet: create data access object of the Directory API and read all business systems which are returned by the
query as well as print out their identifiers and parties
List<BusinessSystem> bs = directory.readBusinessSystemIn(directory
.queryBusinessSystemIn());
System.out.println("Business Systems:");
Note: When reviewing the read results of the communication channels there might be some fields which seem to lack the
information which is available in the directory. It might be no surprise that passwords are not returned by API, but
what about the adapter metadata?
In those cases a look into the adapter metadata view of ES Repository (see Figure 9) might be helpful, to check
which information is going to be returned by the API.
Figure 10: NWDS project structure showing the newly added web service client for change list
support
The scope which is of interest for this document contains the change list's basic lifecycle operations {create,
activate, reject}. As in case of the query and read operations, a service (here ChangeListInService) is
used to get the port object. After the context has been set to the port object, a change list data transfer object
of type RestrictedChangeListID is created which is used to specify the change list's name and
language dependent description.
Code snippet: set name and language dependent description to change list object
description.setLanguageCode(changeListDescriptionLanguageCode);
id.setDescription(description);
The activation and rejection of the change list then only need the ID (GUID) of the change list, which is
returned when creating the list. These change list identifiers are important when it comes to the change or
creation of configuration objects. For further details of the implementation see Appendix, Listing 2.
Note: The method checkContent can be used to check consistency of the change list and getCacheState
returns information about the cache distribution and can thus be useful in case of erroneous behavior.
Code snippet: instantiate e.g. business system create object, set the created change list identifier, instantiate the
corresponding business system data object and set its name and master language before creation
create.getBusinessSystem().add(bs);
The same mechanisms apply to the creation of the other configuration objects. The data access object
containing the complete implementation of query, read and create as well as the change list methods can be
found in Appendix, Listing 2.
Then the business component Receiver_Article is created (which does not be maintained in SLD). The
major difference between the creation of business systems and components is the possibility to set inbound
and outbound interfaces to the business components. In this case, the business component is created with
empty interfaces.
Figure 11: Communication component editor showing details of the generated business component (with its
assigned communication channel). The reference to the channel is added by the system after its creation
The newly created business component (Figure 11) now needs a communication channel which we assume
to be a receiver channel of type XI. Therefore only the required information is set. However, some of the
adapter specific attributes, e.g. host, have to be set specifically for your landscape. This is required for
runtime. The settings chosen in this document allow at least a creation of the communication channel.
// channel data
CommunicationChannelDirection direction =
CommunicationChannelDirection.RECEIVER;
Figure 12: Communication channel editor showing details of the generated communication channel with its
adapter specific attributes
With the generated receiver communication channel (see Figure 12) a receiver agreement is created
assuming the receiver interfaces simply is FlightBookingOrderRequest_In of the delivered demo
airline scenario (see Figure 13).
Code snippet: create receiver agreement for business component with communication channel
// communication channel
CommunicationChannelID channelId = new CommunicationChannelID();
//channelId.setPartyID("");
channelId.setChannelID(receiverChannel);
channelId.setComponentID(businessComponent);
Figure 13: Receiver agreement editor showing details of the generated receiver agreement with its receiver
interface and receiver communication channel
After the business component, its receiver channel and agreement have been successfully created, it is kept
in the formerly created change list article-changeList (see Figure 14). All configuration objects can
now be checked for consistency. That is due to the commented activation step in the source code and allows
a manual check in the system (can be checked via checkContent method of the Directory API). The check
only looks for severe issues and allows e.g. incorrectly filled adapter specific attributes in the communication
channel. However, if the settings are not corrected, this will lead to errors during runtime.
Figure 14: Integration Builder change list view showing the generated change list containing the business
component, communication channel and receiver agreement
Why does the printout of the sample application not show any of the created components? That depends on
the change list. If the change list has not been activated the ReadContextCode.ACTIVE setting prevents
from retrieving the created but not yet activated change list objects. Solutions might be settings the context to
ReadContextCode.USER, or programmatically activate the change list.
Appendix
Listing 1: DirectoryApiConfiguration
package com.sap.pi.directory.article;
/**
* @author SAP AG
*
*/
/**
* @return
*/
public static String getUserid() {
return USERID;
}
/**
* @return
*/
public static String getPassword() {
return PASSWORD;
}
/**
* @return
*/
public static String getSERVER_NAME() {
return SERVER_NAME;
}
/**
* @return
*/
public static String getSERVER_PORT() {
return SERVER_PORT;
}
}
Listing 2: DirectoryApiDAO
package com.sap.pi.directory.article;
import java.net.MalformedURLException;
import java.util.List;
import java.util.Map;
import javax.xml.ws.BindingProvider;
import com.sap.xi.basis.BusinessComponent;
import com.sap.xi.basis.BusinessComponentCreateChangeIn;
import com.sap.xi.basis.BusinessComponentIn;
import com.sap.xi.basis.BusinessComponentInService;
import com.sap.xi.basis.BusinessComponentQueryIn;
import com.sap.xi.basis.BusinessComponentQueryOut;
import com.sap.xi.basis.BusinessComponentReadIn;
import com.sap.xi.basis.BusinessComponentReadOut;
import com.sap.xi.basis.BusinessSystem;
import com.sap.xi.basis.BusinessSystemCreateChangeIn;
import com.sap.xi.basis.BusinessSystemIn;
import com.sap.xi.basis.BusinessSystemInService;
import com.sap.xi.basis.BusinessSystemQueryIn;
import com.sap.xi.basis.BusinessSystemQueryOut;
import com.sap.xi.basis.BusinessSystemReadIn;
import com.sap.xi.basis.ChangeListCreateOut;
import com.sap.xi.basis.ChangeListIn;
import com.sap.xi.basis.ChangeListInService;
import com.sap.xi.basis.CommunicationChannel;
import com.sap.xi.basis.CommunicationChannelCreateChangeIn;
import com.sap.xi.basis.CommunicationChannelDirection;
import com.sap.xi.basis.CommunicationChannelID;
import com.sap.xi.basis.CommunicationChannelIn;
import com.sap.xi.basis.CommunicationChannelInService;
import com.sap.xi.basis.CommunicationChannelQueryIn;
import com.sap.xi.basis.CommunicationChannelQueryOut;
import com.sap.xi.basis.CommunicationChannelReadIn;
import com.sap.xi.basis.CommunicationChannelReadOut;
import com.sap.xi.basis.CommunicationComponentID;
import com.sap.xi.basis.ConfigurationObjectModifyOut;
import com.sap.xi.basis.DesignObjectID;
import com.sap.xi.basis.GenericProperty;
import com.sap.xi.basis.LogMessageCollection;
import com.sap.xi.basis.MessageHeaderID;
import com.sap.xi.basis.ReadContextCode;
import com.sap.xi.basis.ReceiverAgreement;
import com.sap.xi.basis.ReceiverAgreementCreateChangeIn;
import com.sap.xi.basis.ReceiverAgreementIn;
import com.sap.xi.basis.ReceiverAgreementInService;
import com.sap.xi.basis.ReceiverAgreementQueryIn;
import com.sap.xi.basis.ReceiverAgreementQueryOut;
import com.sap.xi.basis.ReceiverAgreementReadIn;
import com.sap.xi.basis.ReceiverAgreementReadOut;
import com.sap.xi.basis.RestrictedBusinessComponent;
import com.sap.xi.basis.RestrictedBusinessSystem;
import com.sap.xi.basis.RestrictedChangeListID;
import com.sap.xi.basis.RestrictedCommunicationChannel;
import com.sap.xi.basis.RestrictedReceiverAgreement;
import com.sap.xi.basis.RestrictedSenderAgreement;
import com.sap.xi.basis.SenderAgreement;
import com.sap.xi.basis.SenderAgreementCreateChangeIn;
import com.sap.xi.basis.SenderAgreementIn;
import com.sap.xi.basis.SenderAgreementInService;
import com.sap.xi.basis.SenderAgreementQueryIn;
import com.sap.xi.basis.SenderAgreementQueryOut;
import com.sap.xi.basis.SenderAgreementReadIn;
import com.sap.xi.basis.SenderAgreementReadOut;
import com.sap.xi.basis.global.LONGDescription;
/**
* @author SAP AG
*
*/
public class DirectoryApiDAO {
// BUSINESS SYSTEM
/**
* @return
*/
public final List<CommunicationComponentID> queryBusinessSystemIn() {
try {
// get web service
BusinessSystemInService service = new
BusinessSystemInService();
// get port
BusinessSystemIn systemComp =
service.getBusinessSystemInPort();
LogMessageCollection logMsgs =
result.getLogMessageCollection();
System.out.println(logMsgs.getLogMessageBusinessSystem().get(i)
.getLogMessageItem().getMessage());
}
list = result.getBusinessSystemID();
} catch (MalformedURLException e) {
e.printStackTrace();
}
return list;
}
/**
* @param ids
* @return
*/
public final List<BusinessSystem> readBusinessSystemIn(
List<CommunicationComponentID> ids) {
try {
// get web service
BusinessSystemInService service = new
BusinessSystemInService();
// get port
BusinessSystemIn systemComp =
service.getBusinessSystemInPort();
} catch (MalformedURLException e) {
e.printStackTrace();
}
return businessSystem;
}
/**
* @param changeList
* @param masterLanguage
* @param id
*/
public final void createBusinessSystem(ChangeListCreateOut changeList,
String masterLanguage, CommunicationComponentID id) {
try {
BusinessSystemInService service = new
BusinessSystemInService();
BusinessSystemIn comp = service.getBusinessSystemInPort();
create.setChangeListID(changeList.getChangeListID()
.getChangeListID());
RestrictedBusinessSystem bs = new RestrictedBusinessSystem();
bs.setMasterLanguage(masterLanguage);
bs.setBusinessSystemID(id);
create.getBusinessSystem().add(bs);
System.out.println(logMsgs.getLogMessageBusinessSystem().get(i)
.getLogMessageItem().getMessage());
}
if
(out.getLogMessageCollection().getLogMessageBusinessSystem()
.size() != 0) {
System.out.println(out.getLogMessageCollection()
.getLogMessageBusinessSystem().get(0));
}
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
// BUSINESS COMPONENT
/**
* @return
*/
public final List<CommunicationComponentID> queryBusinessComponentIn() {
List<CommunicationComponentID> list = null;
try {
// get service
BusinessComponentInService service = new
BusinessComponentInService();
// get port
BusinessComponentIn businessComp = service
.getBusinessComponentInPort();
LogMessageCollection logMsgs =
result.getLogMessageCollection();
System.out.println(logMsgs.getLogMessageBusinessComponent()
.get(i).getLogMessageItem().getMessage());
}
list = result.getBusinessComponentID();
} catch (MalformedURLException e) {
e.printStackTrace();
}
return list;
}
/**
* @param list
* @return
*/
public final List<BusinessComponent> readBusinessComponentIn(
List<CommunicationComponentID> list) {
List<BusinessComponent> businessComponents = null;
try {
// get service
BusinessComponentInService service = new
BusinessComponentInService();
// get port
BusinessComponentIn businessComp = service
.getBusinessComponentInPort();
businessComponents = result.getBusinessComponent();
} catch (MalformedURLException e) {
e.printStackTrace();
}
return businessComponents;
/**
* @param changeList
* @param masterLanguage
* @param id
* @param inboundObjectId
* @param outboundObjectId
*/
public final void createBusinessComponent(ChangeListCreateOut changeList,
String masterLanguage, CommunicationComponentID id,
List<DesignObjectID> inboundObjectId,
List<DesignObjectID> outboundObjectId) {
try {
BusinessComponentInService service = new
BusinessComponentInService();
BusinessComponentIn comp =
service.getBusinessComponentInPort();
System.out.println(logMsgs.getLogMessageBusinessComponent()
.get(i).getLogMessageItem().getMessage());
}
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
// Sender AGREEMENT
/**
* @return
*/
public final List<MessageHeaderID> querySenderAgreementIn() {
List<MessageHeaderID> list = null;
try {
// get service
SenderAgreementInService service = new
SenderAgreementInService();
// get port
SenderAgreementIn interfaceComp = service
.getSenderAgreementInPort();
LogMessageCollection logMsgs =
result.getLogMessageCollection();
System.out.println(logMsgs.getLogMessageSenderAgreement()
.get(i).getLogMessageItem().getMessage());
}
list = result.getSenderAgreementID();
} catch (MalformedURLException e) {
e.printStackTrace();
}
return list;
}
/**
* @param list
* @return
*/
public final List<SenderAgreement> readSenderAgreementIn(
List<MessageHeaderID> list) {
List<SenderAgreement> agrees = null;
try {
// get service
SenderAgreementInService service = new
SenderAgreementInService();
// get port
SenderAgreementIn comp = service.getSenderAgreementInPort();
agrees = result.getSenderAgreement();
} catch (MalformedURLException e) {
e.printStackTrace();
}
return agrees;
}
/**
* @param changeList
* @param masterLanguage
* @param header
* @param channel
* @param softwareComponentVersion
*/
public final void createSenderAgreement(ChangeListCreateOut changeList,
String masterLanguage, MessageHeaderID header,
CommunicationChannelID channel, String
softwareComponentVersion) {
try {
SenderAgreementInService service = new
SenderAgreementInService();
SenderAgreementIn comp = service.getSenderAgreementInPort();
senderAgreement.setMasterLanguage(masterLanguage);
// sender agreement
senderAgreement.setSenderAgreementID(header);
// communication channel
senderAgreement.setCommunicationChannel(channel);
senderAgreement
.setSoftwareComponentVersion(softwareComponentVersion);
create.getSenderAgreement().add(senderAgreement);
System.out.println(logMsgs.getLogMessageSenderAgreement()
.get(i).getLogMessageItem().getMessage());
}
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
// RECEIVER AGREEMENT
/**
* @return
*/
public final List<MessageHeaderID> queryReceiverAgreementIn() {
List<MessageHeaderID> list = null;
try {
// get service
ReceiverAgreementInService service = new
ReceiverAgreementInService();
// get port
ReceiverAgreementIn interfaceComp = service
.getReceiverAgreementInPort();
LogMessageCollection logMsgs =
result.getLogMessageCollection();
System.out.println(logMsgs.getLogMessageReceiverAgreement()
.get(i).getLogMessageItem().getMessage());
}
list = result.getReceiverAgreementID();
} catch (MalformedURLException e) {
e.printStackTrace();
}
return list;
}
/**
* @param list
* @return
*/
public final List<ReceiverAgreement> readReceiverAgreementIn(
List<MessageHeaderID> list) {
List<ReceiverAgreement> agrees = null;
try {
// get service
ReceiverAgreementInService service = new
ReceiverAgreementInService();
// get port
ReceiverAgreementIn comp =
service.getReceiverAgreementInPort();
agrees = result.getReceiverAgreement();
} catch (MalformedURLException e) {
e.printStackTrace();
}
return agrees;
}
/**
* @param changeList
* @param masterLanguage
* @param header
* @param channelId
*/
public final void createReceiverAgreement(ChangeListCreateOut changeList,
String masterLanguage, MessageHeaderID header,
CommunicationChannelID channelId) {
try {
ReceiverAgreementInService service = new
ReceiverAgreementInService();
ReceiverAgreementIn comp =
service.getReceiverAgreementInPort();
// receiver agreement id
recAgreement.setReceiverAgreementID(header);
// communication channel
recAgreement.setCommunicationChannel(channelId);
create.getReceiverAgreement().add(recAgreement);
System.out.println(logMsgs.getLogMessageReceiverAgreement()
.get(i).getLogMessageItem().getMessage());
}
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
// COMMUNICATION CHANNEL
/**
* @return
*/
public final List<CommunicationChannelID> queryCommunicationChannelIn() {
List<CommunicationChannelID> list = null;
try {
// get service
CommunicationChannelInService service = new
CommunicationChannelInService();
// get port
CommunicationChannelIn interfaceComp = service
.getCommunicationChannelInPort();
LogMessageCollection logMsgs =
result.getLogMessageCollection();
System.out.println(logMsgs.getLogMessageCommunicationChannel()
.get(i).getLogMessageItem().getMessage());
}
list = result.getCommunicationChannelID();
} catch (MalformedURLException e) {
e.printStackTrace();
}
return list;
}
/**
* @param list
* @return
*/
public final List<CommunicationChannel> readCommunicationChannelIn(
List<CommunicationChannelID> list) {
try {
// get service
CommunicationChannelInService service = new
CommunicationChannelInService();
// get port
CommunicationChannelIn comp = service
.getCommunicationChannelInPort();
channel = result.getCommunicationChannel();
} catch (MalformedURLException e) {
e.printStackTrace();
}
return channel;
}
CommunicationChannelInService service;
try {
service = new CommunicationChannelInService();
CommunicationChannelIn comp = service
.getCommunicationChannelInPort();
// master language
channel.setMasterLanguage(masterLanguage);
// communication channel
channel.setCommunicationChannelID(channelID);
// channel data
channel.setDirection(direction);
channel.setTransportProtocol(transportProtocol);
channel.setTransportProtocolVersion(transportProtocolVersion);
channel.setMessageProtocol(messageProtocol);
channel.setMessageProtocolVersion(messageProtocolVersion);
channel.getAdapterSpecificAttribute().add(properties.get(i));
}
create.getCommunicationChannel().add(channel);
System.out.println(logMsgs.getLogMessageCommunicationChannel()
.get(i).getLogMessageItem().getMessage());
}
} catch (MalformedURLException e) {
e.printStackTrace();
}
return channelID.getChannelID();
}
/**
* @param changeListName
* @param changeListDescription
* @param changeListDescriptionLanguageCode
* @return
*/
public final ChangeListCreateOut createChangeList(String changeListName,
String changeListDescription,
String changeListDescriptionLanguageCode) {
ChangeListInService service;
try {
service = new ChangeListInService();
ChangeListIn comp = service.getChangeListInPort();
description.setLanguageCode(changeListDescriptionLanguageCode);
id.setDescription(description);
return comp.create(id);
} catch (MalformedURLException e) {
e.printStackTrace();
}
return null;
}
/**
* @param changeList
*/
public final void activateChangeList(ChangeListCreateOut changeList) {
try {
ChangeListInService service = new ChangeListInService();
System.out.println(logMsgs.getLogMessageChangeList().get(i)
.getLogMessageItem().getMessage());
}
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
/**
* @param changeList
*/
public final void rejectChangeList(ChangeListCreateOut changeList) {
ChangeListInService service;
try {
service = new ChangeListInService();
DirectoryApiConfiguration.getPassword());
comp.revert(changeList.getChangeListID().getChangeListID());
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
/**
* @param bindingProvider
* @param user
* @param password
*/
private final void setupContext(BindingProvider bindingProvider,
String user, String password) {
javax.xml.ws.BindingProvider bp = bindingProvider;
Map<String, Object> context = bp.getRequestContext();
StringBuffer sb = new StringBuffer(
"Request context of service endpoint");
if (context == null) {
System.out.println(sb.append(" is null").toString());
} else {
String endpointAddress = (String) context
.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
String endPointPrefix = "http://";
String addressTailWithHostAndPort = endpointAddress
.substring(endPointPrefix.length());
endpointAddress = new StringBuffer(endPointPrefix).append(
DirectoryApiConfiguration.getSERVER_NAME()).append(
":" + DirectoryApiConfiguration.getSERVER_PORT())
.append(
addressTailWithHostAndPort
.substring(addressTailWithHostAndPort
.indexOf("/"))).toString();
context.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
endpointAddress);
context.put(BindingProvider.USERNAME_PROPERTY, user);
context.put(BindingProvider.PASSWORD_PROPERTY, password);
}
}
}
Listing 3: DirectoryAPIMain
package com.sap.pi.directory.article;
import java.util.ArrayList;
import java.util.List;
import com.sap.xi.basis.BusinessComponent;
import com.sap.xi.basis.BusinessSystem;
import com.sap.xi.basis.ChangeListCreateOut;
import com.sap.xi.basis.CommunicationChannel;
import com.sap.xi.basis.CommunicationChannelDirection;
import com.sap.xi.basis.CommunicationChannelID;
import com.sap.xi.basis.CommunicationComponentID;
import com.sap.xi.basis.DesignObjectID;
import com.sap.xi.basis.GenericProperty;
import com.sap.xi.basis.MessageHeaderID;
import com.sap.xi.basis.ReceiverAgreement;
import com.sap.xi.basis.SenderAgreement;
/**
* @param args
*/
public static void main(String[] args) {
// --- W R I T E --- //
// create variables
String businessComponent = "Receiver_Article";
String receiverChannelIdString =
"ZArticle_GeneratedReceiverChannel_XI";
// channel data
CommunicationChannelDirection direction =
CommunicationChannelDirection.RECEIVER;
// communication channel
CommunicationChannelID channelId = new CommunicationChannelID();
//channelId.setPartyID("");
channelId.setChannelID(receiverChannel);
channelId.setComponentID(businessComponent);
directory.createReceiverAgreement(changeList, masterLanguage,
header,
channelId);
// --- R E A D --- //
System.out.println("Business Systems:");
for (int i = 0; i < bs.size(); i++) {
// display party and id
System.out.println(bs.get(i).getBusinessSystemID().getPartyID()
+ "#" +
bs.get(i).getBusinessSystemID().getComponentID());
}
System.out.println("#------------------#");
List<BusinessComponent> bc = directory
.readBusinessComponentIn(directory.queryBusinessComponentIn());
System.out.println("Business Components:");
for (int i = 0; i < bc.size(); i++) {
// display party and id
System.out
.println(bc.get(i).getBusinessComponentID().getPartyID()
+ "#"
+ bc.get(i).getBusinessComponentID()
.getComponentID());
}
List<SenderAgreement> sa = directory.readSenderAgreementIn(directory
.querySenderAgreementIn());
System.out.println("Sender Agreements:");
for (int i = 0; i < sa.size(); i++) {
// display id
System.out.println(sa.get(i).getSenderAgreementID()
.getSenderComponentID());
}
List<ReceiverAgreement> ra = directory
.readReceiverAgreementIn(directory.queryReceiverAgreementIn());
System.out.println("Receiver Agreements:");
for (int i = 0; i < ra.size(); i++) {
// display id
System.out.println(ra.get(i).getReceiverAgreementID()
.getReceiverComponentID());
}
List<CommunicationChannel> cc = directory
.readCommunicationChannelIn(directory
.queryCommunicationChannelIn());
System.out.println("Communication Channels:");
for (int i = 0; i < cc.size(); i++) {
// display id
System.out.println(cc.get(i).getCommunicationChannelID()
.getChannelID());
}
}
}
Related Content
[1] Integration Directory API.
http://help.sap.com/saphelp_nwpi71/helpdata/en/46/6dca42e5c269dfe10000000a11466f/frameset.htm
[2] SAP NetWeaver Process Integration 7.1. http://www.sdn.sap.com/irj/sdn/nw-
pi71;jsessionid=(J2EE3414700)ID0801759550DB00954840661228332715End.
[3] Li, William: Directory API Development.
http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/11655%3Fpage%3Dlast%26x-
showcontent%3Doff%26x-maxdepth%3D0. 20.10.2008.
Copyright
© Copyright 2009 SAP AG. All rights reserved.
No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG.
The information contained herein may be changed without prior notice.
Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors.
Microsoft, Windows, Excel, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation.
IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5, System x, System z, System z10, System z9, z10, z9,
iSeries, pSeries, xSeries, zSeries, eServer, z/VM, z/OS, i5/OS, S/390, OS/390, OS/400, AS/400, S/390 Parallel Enterprise Server,
PowerVM, Power Architecture, POWER6+, POWER6, POWER5+, POWER5, POWER, OpenPower, PowerPC, BatchPipes,
BladeCenter, System Storage, GPFS, HACMP, RETAIN, DB2 Connect, RACF, Redbooks, OS/2, Parallel Sysplex, MVS/ESA, AIX,
Intelligent Miner, WebSphere, Netfinity, Tivoli and Informix are trademarks or registered trademarks of IBM Corporation.
Linux is the registered trademark of Linus Torvalds in the U.S. and other countries.
Adobe, the Adobe logo, Acrobat, PostScript, and Reader are either trademarks or registered trademarks of Adobe Systems
Incorporated in the United States and/or other countries.
Oracle is a registered trademark of Oracle Corporation.
UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group.
Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of
Citrix Systems, Inc.
HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C®, World Wide Web Consortium, Massachusetts
Institute of Technology.
Java is a registered trademark of Sun Microsystems, Inc.
JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by
Netscape.
SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP Business ByDesign, and other SAP products and services mentioned
herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and other countries.
Business Objects and the Business Objects logo, BusinessObjects, Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsius, and
other Business Objects products and services mentioned herein as well as their respective logos are trademarks or registered
trademarks of Business Objects S.A. in the United States and in other countries. Business Objects is an SAP company.
All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document
serves informational purposes only. National product specifications may vary.
These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP
Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or
omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the
express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an
additional warranty.