Wednesday, 15 August 2018

YMkt application integration via SAP CPI/ SAP HCI

Below is an idea on how we are connecting to the YMkt application/system

There are two ways to connect to YMkt application. Basically YMkt is a ODATA application.

1. Through ODATA adapter in CPI
2.Through HTTP Adapter in CPI

When using ODATA adapter, can directly access the application.
But when accessing via HTTP adapter, then X-CSRF token exchange must be happened.

CSRF token Handling:

By using content modifier at before step, we need to pass in Header parameter as

x-csrf-token - constant - value as fetch

Set Cookie using groovy script:

Even set cookie needed to pass it to Ymkt receiver application.

import com.sap.gateway.ip.core.customdev.util.Message;
import groovy.xml.*;
import java.io.*;

def Message processData(Message message)
{
    def headers = message.getHeaders();
    def cookie = headers.get("Set-Cookie");
    StringBuffer bufferedCookie = new StringBuffer();
    for (Object item : cookie)
    {
        bufferedCookie.append(item + "; ");     
    }
    message.setHeader("Cookie", bufferedCookie.toString());
   
   
    def messageLog = messageLogFactory.getMessageLog(message);
    if(messageLog != null)
    {
        messageLog.setStringProperty("Logging_Cookie", bufferedCookie.toString());
    }
    return message;
}



No comments:

Post a Comment