Skip to Content
Technical Articles

CPI attachment dowloader

After Fatih Pense posted his tool for inspecting CPI log files (http and trace), I decided to improve my tool and publish it on NPM too. So thanks to Fatih for the inspiration and drive!

The tool I built allows you to download attachments from log entries in CPI, allowing you to inspect the integration flow.

I built this when I was building a SOAP service that would integrate a 3rd party application into SAP SuccessFactors HCM. The 3rd party application calls my SOAP service for every change in employee data to update SuccessFactors. This means that the integration flow can be called several times per minute and trying to find a specific message during UAT in case of issues can be very time consuming.

So I decided to build a tool that would download the attachments for each exchange to a folder. Each exchange would get its own folder that had all attachments. Using the global search function in VS Code (https://code.visualstudio.com/), I could find specific exchanges based on the received payload or the response.

The tool I now published allows you to do the same for your own tenant. Better yet, it allows you to add multiple tenants and download logs for every deployed artifact on that tenant. It also keeps track of when the logs were last downloaded for each artifact.

There are some requirements though:

  • Node.js must be installed on your computer
  • The mime-type for the attachment must be set correctly in order for the app to properly determine the attachment’s extension

To add an XML attachment:

def Message processData(Message message) {
    def String body = message.getBody(String.class);
    def messageLog = messageLogFactory.getMessageLog(message);
    if(messageLog != null){
        messageLog.addAttachmentAsString("title", body, "text/xml");
    }
}

To add a csv file:

def Message processData(Message message) {
    def String body = message.getBody(String.class);
    def messageLog = messageLogFactory.getMessageLog(message);
    if(messageLog != null){
        messageLog.addAttachmentAsString("title", body, "text/csv");
    }
}

The app is open source and can be found here where you will also find instruction for installation and usage.

Please leave a comment if you have any suggestions or log an issue on GitHub if you run into any.

Cheers!

Ivo

Be the first to leave a comment
You must be Logged on to comment or reply to a post.