Access Headers and Properties
This is the recommended way to access headers and properties in message mapping. You need to create a Groovy script that contains two functions: get Header() and get Property(). These functions take the header name or property name as input and return the value of the header or property.
Once you have created the script, you need to assign it to the mapping expression in the message mapping. You can do this by clicking on the Functions tab in the message mapping and then selecting the Add button. In the Add Function dialog, select the Custom Function option and then select the script that you created.
Implementation
We will create the iflow in which we will access the headers and properties.
- Open the Integration Flow in the edit mode.
- Add the headers and Properties in the Content Modifiers. In our case We have added the Exchange Property (Document_Number) which we are getting the source value form the Global Variable.
- I have connected the Receiver with Request-Reply using HTTP to fetch some data, In our case this not main objective. We will primarily focusing on Access the exchange Property in Message mapping.
- Add the Message Mapping step and add the source and the Target XSD.
- This is very basic example, Suppose at the target side there is a node called Document Number but instead of mapping it with source you want to write the value to this node that you have stored in the exchange property.
- In such cases, The Custom Functions played a crucial role. To open the Mapping Expression assign Constant to the Document Number.
- In the Functions list, Click on the Create.
- Provide the name of the Script.
- Paste the following script and CLick Ok.
"def String getProperty(String propertyName, MappingContext context) {
def propertyValue = context.getProperty(propertyName);
return propertyValue;
}"
- Provide the Name of the Property to the Constant and Map it with the Target Node.
- Save and Deploy the Integration Flow you Target node will have the value of your Exchange Property.
Do you want to
learn more about integration?
We are dedicated to make our knowledge accessible. You can either figure it out by yourself or you can let us give you a hand.
Let us take care of your integration.
We are SAP Certified and we can make your project happen. Explore our services and contact us. We will be happy to take on your project.
View Our Services