Directory API has been used by many companies to streamline processes and ease situations where manual configuration of Integration Directory objects is not the ideal solution, such as the updating of the communication channels after transport. If a program can carry out this task, then it can minimize mistakes, speed up deployment and increase security.
Directory API has gone through different iterations, due to added functionalities and new objects introduced in newer releases. The older version (XI 3.0, PI 7.0x, PI 7.1x) of the API can no longer be used with the newer versions of PI. As the result, the development of the API has also changed.
The previous version of the API can be referenced in: Directory API Development
In this blog, I will introduce the basic development of using the PI 7.3x Directory API. The example can be used as a template to start a Directory API project, and hopefully overcome some of the initial hurdles.
Scenario:
The sample scenario is simply to get the number of Integrated Configuration objects, which was introduced in PI 7.1.
Pre-requisite:
The following roles must be added to the username executing the API:
Step-by-Step Guide
The ESR contains the Service Interface of the API and using NWDS, we can import the WSDL of the service interface directly from the ESR. (The NWDS version should at least match the PI versoin.)
package com.demo.dirapi;
import java.util.List;
import javax.xml.ws.BindingProvider;
import com.sap.xi.basis.IntegratedConfigurationIn;
import com.sap.xi.basis.IntegratedConfigurationInService;
import com.sap.xi.basis.IntegratedConfigurationQueryIn;
import com.sap.xi.basis.IntegratedConfigurationQueryOut;
import com.sap.xi.basis.MessageHeaderID;
public class IntegratedConfiguration {
private static String apiURL = "/IntegratedConfigurationInService/IntegratedConfigurationInImplBean?wsdl=binding&mode=ws_policy";
private String serverPort = "usphlvm1426:50000";
private String user = "demo";
private String password = "abcd1234";
private String url = new String();
private IntegratedConfigurationIn port;
public IntegratedConfiguration() {
setURL(serverPort);
try {
port = getPort();
}
catch (Exception e) {
e.printStackTrace();
}
}
public List query() {
IntegratedConfigurationQueryIn queryIn = new IntegratedConfigurationQueryIn();
MessageHeaderID msgHdr = new MessageHeaderID();
queryIn.setIntegratedConfigurationID(msgHdr);
IntegratedConfigurationQueryOut queryOut = port.query(queryIn);
List lMsgHdr = queryOut.getIntegratedConfigurationID();
return lMsgHdr;
}
private void setURL(String serverPort) {
if (serverPort == null)
return;
else
this.url = this.url.concat("http://").concat(serverPort).concat(apiURL);
}
private IntegratedConfigurationIn getPort() throws Exception{
IntegratedConfigurationIn port = null;
try {
IntegratedConfigurationInService service = null;
service = new IntegratedConfigurationInService();
port = (IntegratedConfigurationIn) service.getIntegratedConfigurationIn_Port();
BindingProvider bp = (BindingProvider)port;
bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, user);
bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
if (url.length() != 0)
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
}
catch (Exception ex){
ex.printStackTrace();
}
return port;
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
IntegratedConfiguration test = new IntegratedConfiguration();
List listMsgHdr = test.query();
System.out.println("Done - number of configurations = " + listMsgHdr.size());
}
}
Note: The apiURL value can be obtained by going the the WSNavigator.You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
37 | |
25 | |
17 | |
13 | |
7 | |
7 | |
7 | |
6 | |
6 | |
6 |