Introduction

This blog post is part of a series of blogs demonstrating how to feed data on the SAP Emarsys from SAP Commerce.

In this part, I demonstrate the developments on the SAP CPI that receives the customer data from SAP Commerce, does the necessary transformations and enrichments, then send it to SAP Emarsys.

My colleague Rodrigo Cardoso wrote a great blog showing how to enable this integration on the SAP Commerce Cloud.

TLDR

The SAP CPI package with all the artifacts can be downloaded on GitHub.

Process Flow

This blog demonstrates the following process:

  1. A customer is created on the SAP Commerce, triggering an event;
  2. This event starts a job that sends the customer data to an iFlow on the SAP Cloud Integration through an HTTP post;
  3. This first iFlow transforms the data to the SAP Emarsys expected format and stores it on a JMS queue, making this replication process asynchronous;
  4. A second iFlow pools the JMS queue, fetch the data, and calls a third iFlow. This last iFlow is responsible for generating the HTTP Header WSSE necessary to authenticate in the SAP Emarsys tenant;
  5. The data is sent to the SAP Emarsys tenant.

This diagram briefly shows the process described above.

Proccess%20Flow

Preparation

Import of Digital Certificates

The communication between the SAP Commerce, SAP CPI, and SAP Emarsys tenants use the HTTPS protocol. 

The following steps are necessary to acquire and import the digital certificates on the SAP CPI tenant:

  1. Go to the Connectivity Tests app on the Integrations Monitor.

  2. Enter api.emarsys.net on the host, uncheck the Valid Server Certificate Required, and click on Send button;

  3. Download the digital certificate chain locally;
  4. Decompress the ZIP file locally;
  5. On the SAP CPI, open the Keystore app;
  6. Click on Add, Certificate;
  7. In the popup, click on browse and select the file on the image. This file is the root certificate and the only one necessary to establish the HTTPS connection between SAP CPI and SAP Emarsys;

  8. Execute steps 1 and 2 again, but with the flag, Valid Server Certificate Required checked. You must see a successful response.

Creation of Security Materials

As described in the SAP Emarsys API documentation, their API requires a WSSE authentication. For this reason, I created the Emarsys security material with the user and password provided by the SAP Emarsys tenant administrator.

Integration Flows

As mentioned in the Process Flow, I created three iFlows:

1. Receive Contacts from SAP Commerce

This iFlow receives the customer data from SAP Commerce, transforms this customer data to the SAP Emarsys contact data format, and stores the data on a JMS queue.

The iFlows proceed as follows:

  1. SAP Commerce sends the customer data using the HTTPS protocol (method POST). Just for simplicity, I disabled the CSRF protection;

  2. The Set Parameters step creates two parameters, SourceAgency and TargetAgency, in case of a value mapping usage;
  3. The generic Mapper step is a script that converts the customer data to the contact data format. It uses the POGOs concept described in Eng Swee Yeoh’s blog;
  4. Then the data is sent to a JMS queue, making the replication process asynchronous, as explained on Mandy Crimmel’s blog.

2. Replicate Contacts to SAP Emarsys

This iFlow pools the JMS queue, enriches the data, logs the customers processed, and calls the HTTP WSSE Header generator.

Also, this iFlow contains an exception subprocess with the necessary controls to retry to send the customer data to SAP Emarsys in case of failure.

 

The iFlow proceeds as follows:

  1. Pools the JMS queue, to fetch the contact data;

  2. Set the following message headers’:
    1.  Content-Type; 
    2. Secure Material – The secure material is an external parameter that must be set with the object created on step creation of security materials, this header is used by the HTTP WSSE Header generator iFlow.

  3. Set the following properties. These properties are externalized parameters to make the iFlow flexible. 
    1. KeyId – This is the SAP Emarsys ID key field;
    2. ContactListId – The SAP Emarsys contact list ID to which the contact will be added;
    3. MaxRetries – Number of maximum retries if an error when sending the contact data to the SAP Emarsys fails.
  4. Set the message body with the format expected by the SAP Emarsys API;
  5. Logs the processed contacts, based on the SAP Emarsys ID key that is provided in the earlier step.
  6. Calls the HTTP WSSE Header generator passing the secure material on the message header.
  7. Send the contact data to the SAP Emarsys tenant.

3. Generating the HTTP Header WSSE

This iFlow is used to generate the HTTP Header WSSE required by the SAP Emarsys API as the authentication method.

It is called through the process direct adapter and expects to receive the message header SecureMaterial, which contains the SAP CPI security material ID used to generate the HTTP Header.

It is composed of three Groovy scripts that do the following:

  1. Fetch the SAP CPI security material data;
  2. Generates the HTTP Header WSSE.

Monitoring

Through the SAP CPI Monitor Messaging Processing app, you can check the processed messages.

To check all the related iFlows to a specific customer replication you can use the correlation ID that is shared between all the iFlows related to a message received from the SAP Commerce.

Also, as the iFlow that sends the contact data to SAP Emarsys logs the key ID, you can filter the messages based on the SAP Emarsys contact key ID, in this case, the field e-mail (id=3), and then obtain the correlation ID to find all the related messages.

Conclusion

Please, share your feedback and thoughts in a comment.

Also, take the time to visit my colleague Rodrigo Cardoso‘s profile to find out more information about the SAP Commerce and SAP Emarsys integration.

And, I encourage you to visit the SAP Emarsys Commerce Cloud Integration blogs to read other posts on this topic and the SAP Emarsys Commerce Cloud Integration questions to post and answer questions.

References

 

 

Sara Sampaio

Sara Sampaio

Author Since: March 10, 2022

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x