Tuesday 17 September 2019

Allowed Header in Runtime Configurations in iflow SAP CPI


Allowed Header in the integration flow in Runtime Configurations


SapAuthenticatedUserName - To identify the Username that calls the integration flow

Note: If the sender channel is configured to use client certificate authentication, no such header is set (as it is not available in this case). Only for User Role it can be used.

CamelHttpUrl - Refers to the complete URL called, without query parameters

 For Example: CamelHttpUrl:https://XXXX-iflmap.hcisbp.XXX.hana.ondemand.com/http/dev/SF/c4c/fileupload

CamelHttpQuery - Refers to the query string that is contained in the request URL.

CamelHttpMethod - Refers to the incoming method names used to make the request. These methods are GET, POST, PUT, DELETE, and so on.

 For Example: CamelHttpMethod:POST

CamelServletContextPath - Refers to the path specified in the address field of the channel.

 For Example: CamelServletContextPath:/dev/SF/c4c/fileupload

Script used to read the header values:

def headers = message.getHeaders()
def userName = headers.get("SapAuthenticatedUserName")

Result of the above script:

SapAuthenticatedUserName:S0020XXXXXXX  (in header)

------------------------------------------------------------------------------------

Cheers!!!



Monday 2 September 2019

Logging Cookie for session handling Csrf Token - SAP CPI

There is a required step which need to used, when using the CSRF-Token mechanism. To fetch the CSRF- token, the external system will be called and retrieves the token. Session need to be enabled at header to maintain the token to push the actual data to external system.

To Log the Cookie, use the below code after the Get CSRF token request step.

Groovy Script:


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

def Message processData(Message message)
{
def headers = message.getHeaders();

// read cookies to send with next request, especially yMkt Session ID
def cookie = headers.get("Set-Cookie");

StringBuffer bufferedCookie = new StringBuffer();

// bring cookies in right format

for (item in 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;
}

Hope this helps.