CX Works

A single portal for curated, field-tested and SAP-verified expertise for your SAP C/4HANA suite. Whether it's a new implementation, adding new features, or getting additional value from an existing deployment, get it here, at CX Works.

How to Manage SAP Marketing Cloud HTTP Security Sessions with SAP Cloud Platform Integration

How to Manage SAP Marketing Cloud HTTP Security Sessions with SAP Cloud Platform Integration

Integration projects should always consider the best data loading practices for better performance. In large enterprise environments, a huge amount of data is usually sent to SAP Marketing Cloud, so any change to speed up the loading process or increase response times is always welcome.

In this article, we will provide guidance on how to use SAP Cloud Platform Integration (CPI) features to call SAP Marketing Cloud OData API in a proper way, managing HTTP sessions in order to optimize the performance of these calls.

We will show different HTTP handling configurations, the steps to modify them in the CPI iFlow as well as highlighting the result of these session changes in SAP Marketing Cloud.

Table of Contents

SAP Marketing Cloud OData Services

SAP Marketing Cloud provides a list of integration OData Services available for each entity type. The services are used to import master and transaction data into SAP Marketing Cloud.

You may use OData services to load a huge amount of data into SAP Marketing Cloud in order to optimize performance during these calls:

  • Reuse the http sessions (cookie and the x-CSRF token).
    • By reusing the session cookie, you avoid having additional calls to generate a new cookie every time.
    • This leads to improved performance in mass data load or landscapes with large amounts of transaction calls.


SAP Cloud Integration HTTP Handling Features

SAP Cloud Platform Integration (CPI) has different options to handle HTTP sessions that you can change to improve the performance in your integration scenario by re-using sessions through multiple calls.

With these CPI capabilities, you can achieve optimal performance with our interfaces.

In the CPI iFlow, choose one of the following options:

  • HTTP Session Handling “None”: Session handling is switched off
  • HTTP Session Handling “On Exchange”: Each message exchange corresponds to a single session. It is useful when your iFlow breaks down a composite message into multiple single small messages.
  • HTTP Session Handling “On Integration Flow”: Only one session will be used across the whole integration flow executions.

We highly recommend that you read the excellent blog: How to configure Session Handling in Integration Flow. This blog describes in detail all those options in CPI.


Product version

In this article, the following product release version were used.

SAP Marketing Cloud Release: 2005

Upgrade Schedule:

https://www.sap.com/documents/2017/01/867629d8-a27c-0010-82c7-eda71af511fa.html

SAP Cloud Platform integration Build number: 3.21.21

Upgrade Schedule:

https://help.sap.com/viewer/368c481cd6954bdfa5d0435479fd4eaf/Cloud/en-US/023a4725bb734f86be8a5625abe54110.html

Since we have short release cycles, the content in this article might look different from what you find on your SAP Marketing Cloud and SAP Cloud Platform Integration system.

  • SAP Marketing Cloud: Quarterly releases
  • SAP Cloud Platform Integration: Monthly releases


Integration Test Scenario

In our integration test scenario, we are going to call the public OData API Service API_MKT_CONTACT, Contact API with entity ContactOriginData through CPI iFlow to update a few master data Contacts attributes into SAP Marketing Cloud several times.

We highly recommend that you read the following blogs: How to import Contact Data via OData Services to SAP Marketing and How to use the new Contact OData API for SAP Marketing Cloud 1711. These blogs describe in detail how to call OData Marketing APIs.

First, we create a message with multiple nodes in the CPI iFlow. Next, we break it down into smaller single messages and then call the OData API individually.

With each round of tests, we are going to change HTTP Session Handling configuration in the CPI iFlow and then demonstrate the results into SAP Marketing Cloud.


Development Steps

Incoming Message Structure

Basically, we create an XML message that contains some attributes to update the CONTACT: Contact Origin and Contact ID (keys), street name, street number, postal code, and last change timestamp.


<con:UpdateContactOrigin>
  <contactsOrigin>
    <contactOrigin>
      <contactOrigin></contactOrigin>
      <contactID></contactID>
      <streetName></streetName>
      <streetNumber></streetNumber>
      <postalCode></postalCode>
      <originLastChange></originLastChange>
    </contactOrigin>
  </contactsOrigin>
</con:UpdateContactOrigin>


CPI iFlow

Create a simple iFlow to break down a composed message into single small messages and then call SAP Marketing Cloud multiple times.

   

      

Logging Scripts  were used only for this demonstration and test purposes. Use trace log level on CPI to debug and troubleshoot your iFlow tests.


IFLOW STEP DETAILS
LogPayloadBM

Script to log inbound message before the mapping step.


import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
def Message processData(Message message) {     
  def messageLog = messageLogFactory.getMessageLog(message);
  def bodyAsString = message.getBody(String.class);
  messageLog.addAttachmentAsString("InboundPayload", bodyAsString, "text/xml"); 
  return message;
}
General Splitter

Split a composed message into small XML packages. In our demo package, equals 1.


mapAPI_UpdateContact

Simple message mapping step to map XML incoming message structure to OData Message structure.


LogPayloadAM

Script to log outbound message after the mapping step.


import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;  
def Message processData(Message message) {    
  def messageLog = messageLogFactory.getMessageLog(message);
  def bodyAsString = message.getBody(String.class);
  messageLog.addAttachmentAsString("OutboundPayload", bodyAsString, "text/xml"); 
  return message;
}
OData Call

Step to define Receiver Channel

Channel Adapter: OData

Specific OData Configuration: OData Verb PUT and Batch processing


General Tests

ROUND 1: HTTP SESSION HANDLING “NONE”

Business Case Example: 

Customers would use this option in low frequency integration scenarios (submit sales orders in B2B Commerce scenarios that do not produce too many orders) or in a data load that runs once a day with no splitters (calling HTTP services or APIs just once during the runtime process).

In our test case, the integration scenario is receiving one huge file. It needs to be split into small single files and therefore requires calling the HTTP API service multiple times.

Using any Rest Client to send HTTP requests (we used SoapUI in this example), we created an XML message containing five nodes. The iFlow will break it down into five singles messages and then make multiple SAP Marketing API calls.



Example of a single outbound message generated after the mapping iFlow step:


<batchParts>
  <batchChangeSet>
    <batchChangeSetPart>
      <method>PUT</method>
      <ContactOriginData>
        <ContactOriginData>
          <ContactID>testebr@sapcx.com</ContactID>
          <ContactOrigin>SAP_HYBRIS_CONSUMER</ContactOrigin>
          <ContactPostalCode>05374</ContactPostalCode>
          <AddressHouseNumber>1</AddressHouseNumber>
          <LastChangeDateTime>2018-07-17T12:14:14</LastChangeDateTime>
          <OriginDataLastChgUTCDateTime>2018-07-17T12:14:14</OriginDataLastChgUTCDateTime>
          <StreetName>Avenue TEST1</StreetName>
        </ContactOriginData>
      </ContactOriginData>
    </batchChangeSetPart>
  </batchChangeSet>
</batchParts>


In SAP Marketing Cloud, we can find the message data call in the Import Monitor app.



In this test, we defined HTTP Session handling as NONE.



First call, we sent five records to SAP Marketing Cloud. The iFlow called OData API five times which resulted into five opened HTTP sessions.



Second call, we sent again five records to SAP Marketing Cloud. The iFlow called Odata API five more times which resulted into ten opened HTTP sessions.



Considerations:

Complex integration scenarios that execute several API calls during a very short time may result in many opened sessions in the backend. The system may start to refuse connections due to a possible overhead situation.


ROUND 2: HTTP SESSION HANDLING “ON EXCHANGE”

Business Case Example: 

Customers loading daily single batch files from SFTP to SAP Marketing Cloud (customer payments data load). Often, the message in multiple composite messages (typical for API services with restricted request size or limitations on the receiver side) need to be split.

In this test, we defined the HTTP Session handling as on Exchange.



First call, we sent five records to SAP Marketing Cloud. The iFlow called OData API five times which resulted in only one opened HTTP session.



Second call, we sent again five records to SAP Marketing Cloud. The iFlow called Odata API five more times which resulted in two opened HTTP sessions.



Considerations:

Integration scenarios running frequently can save on HTTP sessions using the “on Exchange” mode. This improves performance during a data load. However, scenarios with multiple instances during a very short time and a high throughput might result in many opened sessions in the backend. The system may start to refuse connections due to a possible overhead situation.


ROUND 3: HTTP SESSION HANDLING “ON INTEGRATION FLOW”

Business Case Example: 

Customer would use this option in B2C Commerce scenarios with multiple interactions in real-time that should be replicated into SAP Marketing Cloud. This is a typical high frequency-scenario interface generating thousands of calls on the receiver side.

In this test, we defined the HTTP Session handling as on Integration Flow.



First call, we sent five records to SAP Marketing Cloud. The iFlow called OData API five times which resulted in only one opened HTTP session.



Second call, we sent again five records to SAP Marketing Cloud. The iFlow called Odata API five more times which reused the same previously opened HTTP session.



Considerations:

Integration scenarios running frequently can save on HTTP sessions using the “on Integration Flow” mode. This improves performance during a data load. However, make sure the shared session does not mess up your integration context scenario in case your iFlow has any global parameters that would be shared on runtime.


References

CPI

BLOG Cloud Integration – How to configure Session Handling in Integration Flow

BLOG Cloud Integration – Handling CSRF tokens in SAP Cloud Platform Integration

HELP Cloud Integration – Specify the Runtime Configuration

SAP Marketing Cloud

BLOG SAP Marketing Cloud – How to use the new Contact OData API for SAP Marketing Cloud 1711

BLOG SAP Marketing Cloud – to import Contact Data via OData Services to SAP Marketing

HELP SAP Marketing Cloud – Optimizing Performance During OData Service Calls


Conclusion

In summary, we had two iFlow message executions calling the SAP Marketing Cloud 10 times:

iFlow Method Sessions opened
None 10 sessions
On Exchange 2 sessions
On Integration Flow 1 reused session


In production scenarios, optimizing your integration using a suitable configuration might reduce concurrent sessions (example, from 50000 parallel sessions to less than 5000).



The integration scenarios can be more complex for some customers, such as when the data is coming from multiple origins to SAP Marketing Cloud. For example: 

  • Inbound contacts and product data load
  • Marketing permissions updates, sales interaction in real time
  • Bounces
  • Commerce clickstream events that occur all the time
  • Product and offer recommendations calls from a different channel

This increased workload may slow down server performance and decrease call response times. By properly handling HTTP Sessions and API calls through standard CPI features, you can easily improve your data exchange as well as avoid any possible overhead. 

Make sure to read the documentation and to follow the guidelines and best integration practices recommended for SAP Marketing Cloud.

Guidance and references: SAP Marketing Cloud Help.