FILE/SFTP to REST pass-through interface using DynamicConfigurationBean in SAP PI/PO
We use DynamicConfigurationBean bean to edit the message header for adapter-specific message attributes also to add, delete attributes from message headers. We usually use this when we develop pass-through interface using File and SFTP adapter, recently I came across a situation where I need to send (just pass-through) file from SFTP server to REST api and the receiver was expecting filename in the HTTP Headers. we can do this by using java UDF (creating REST adapter context objects) in graphical mapping or java mapping but this involves development on ESR which I wanted to avoid.
I used DynamicConfigurationBean in the sender SFTP adapter to create REST adapter message headers so that I can later use in REST receiver adapter using ASMA.
- In the Sender SFTP adapter tick ASMA and check File Name
- Under Module tab insert 2 Dynamic Configuration bean like below
- 1 for storing SFTP ASMA parameter to a newly created variable filename
- 1 for creating a new ASMA namespace and assigning variable to the message header.
- When we execute the interface, post successful transfer we can see message headers in message monitor, We can see a new header added (with REST) to the message and it has got the SFTP ASMA FileName value in it.
- Since we have FileName in our message header it is easy for us to use in the receiver REST adapter, under pattern variable replacement I selected Value Source as ASMA and custom attribute. As we obtained FileName attribute in the previous step I am using the same in Attribute name and a new Pattern Element Name(File) is created.
- Now we have sender filename stored in File(Element Name) we will be using in HTTP headers tab like below
We are done we the configuration now, we can test interface and check message log to see file name is being added to the HTTP header or not.
In the audit log we can see file name added to the HTTP header and server has returned 200 that is success, if we do not pass filename API will throw error
We can develop pass-through interface for FILE/SFTP to REST/Webservice based interface