| Recipes by Topic | Recipes by Author| Request Enhancement | Report a bug | Fix documentation|
Amrita Laxmi |
---|
The String and Binary parameters from the Partner Directory can be accessed using a script with the help of getParameter API of the PartnerDirectoryService class.
Download the sample integration flow
Step | Code | Why? |
---|---|---|
Import classes | com.sap.it.api.pd.PartnerDirectoryService |
|
Get the access to the PartnerDirectoryService | def service = ITApiFactory.getApi(PartnerDirectoryService.class, null); |
|
Retrieve the String Parameter | def parameterValue = service.getParameter("ReceiverURL", partnerId , String.class); |
Fetches the Receiver address from the parameter Id 'ReceiverURL' and Partner Id that is available in the Partner Directory |
Retrieve the Binary Parameter and store it in a header | message.setHeader("xsltmappingname","pd:"+partnerId+":xsltmapping:Binary"); |
Fetches the Partner Directory URI for accessing the XSL Transformation and stores it in header 'xsltmappingname' |
Parameterizing Integration Flows Using the Partner Directory
Cloud Integration - Partner Directory - Step-by-Step Example
Cloud Integration - Partner Directory - Partner Dependent XML Structures and IDs
We have a scheduler set at 'Run Once'. A Content Modifier to initialize the Partner ID in a property 'PartnerId' and a script to access the String and Binary parameters for this Partner ID. The AS2 receiver and XSLT mapping validates the fetched parameters.
Download the sample integration flow
This is the script used in this sample
import java.util.HashMap;
import com.sap.it.api.pd.PartnerDirectoryService;
import com.sap.it.api.ITApiFactory;
def Message processData(Message message) {
def service = ITApiFactory.getApi(PartnerDirectoryService.class, null);
if (service == null){
throw new IllegalStateException("Partner Directory Service not found");
}
def map = message.getProperties();
def partnerId = map.get("PartnerId");
if (partnerId == null){
throw new IllegalStateException("Partner ID is not set in the property 'PartnerId'")
}
def parameterValue = service.getParameter("ReceiverURL", partnerId , String.class);
if (parameterValue == null){
throw new IllegalStateException("URL parameter not found in the Partner Directory for the partner ID "+partrnerId);
}
message.setProperty("ReceiverURL", parameterValue );
//reading the Binary parameter
message.setHeader("xsltmappingname","pd:"+partnerId+":xsltmapping:Binary");
return message;
}
Set Property and Header read from Partner Directory is printed for the given source value.