SAP_CPI integration with SFDC
It is well known that Salesforce.com [SFDC] is a popular cloud computing software as a service (SaaS) company that specializes in customer relationship management (CRM). As SAP PI/PO consultants we all might have come across integration of SAP PI/PO with Salesforce either using SOAP adapter or SFDC adapter.
In this blog, we will mainly concentrate on integration of SAP’s cloud based integration platform SAP_CPI with SFDC. The pre-requisites of the integration with SFDC will be same as to that of SAP-PI/PO i.e. first capturing the ‘sessionID’ and ‘TargetURL’ of SFDC; later including the ‘sessionID’ in the SOAP header of the message and sending it to SFDC by means of the ‘TargetURL’.
I will be demonstrating how the message can be triggered from SAP_CPI to SFDC using ‘SOAP’ adapter and how response of a simple ‘query’ operation with SFDC can be received and monitored in SAP_CPI.
- The following is the SAP_CPI integration flow with various controls steps involved for integration with SFDC. The ‘Local Integration Process’ [SFDC_login] is used for logging into SFDC and getting the ‘sessionId’ and ‘serverUrl’ which will be used in further steps of main ‘Integration Process’ for performing query opertions.
2. A timer step is used to automatically trigger the integration flow once it is deployed.
3. In the next step of Content Modifier, we specify the login payload in ‘Message Body’ tab required by SFDC.
The structure of the payload can be obtained by importing the Enterprise wsdl of SFDC in SOAP-UI and referring it to the login request-
Login payload structure from SOAP-UI after importing the Enterprise wsdl of SFDC.
4. In this step we call the ‘Local Integration Process’ (SFDC_login) to perform the login operation with SFDC and obtain the required ‘sessionId’ and ‘serverUrl’.
5. In this Content Modifier step we create a header variable ‘SAP_ApplicationID’ of type Xpath for capturing the ‘username’ from the incoming payload. This is useful for monitoring purpose based on data as it populates the value in ‘Application Message ID’.
Value is set as à concat(‘Test ‘, /p1:login/p1:username)”
In Overview–>Monitor Message Processing; messages can be searched using ‘Application Message ID’.
6. The body of the message is set similar to that of the incoming login payload.
7. In SOAP channel we specify the parameters as below.
In Address we set the login URL of SFDC.
Proxy-Type is set as ‘Internet’.
In URL to WSDL, we select the Enterprise wsdl of SFDC and on selecting the operation ‘login’, the other parameters automatically gets populated.
It also automatically sets the namespace mapping of the Integration flow-
The Enterprise wsdl can be downloaded by logging into SFDC through browser and following the path-
8. In this groovy script we set the login response received from SFDC in the form of payload in message logs of monitoring.
9. In ‘Write Variables’ step; we capture the sessionID and serverURL from the login response received from SFDC.
For session_id, value set as –> /p1:loginResponse/p1:result/p1:sessionId
For server_url, value set as –> /p1:loginResponse/p1:result/p1:serverUrl
Under Overview->Manage Variables; the global variables can be seen as populated.
10. After the Process Call step is completed, the next Content Modifier step captures the global variables value as below, so that it can be used in further operations with SFDC.
The message body is set with the payload of ‘query’ operation of SFDC.
11. As the sessionID has to be set in the SOAP header of the payload, a groovy script is written to perform this task. The code for the groovy script can be referred in the blog –
12. In the next SOAP channel we specify the parameters as below-
The ‘Address’ is dynamically set with serverUrl of SFDC, using the variable from header section in the Content Modifier step-10.
As we want to query records from SFDC, we select the ‘query’ operation on selection of the Enterprise wsdl.
13. In the next groovy script, we capture the ‘queryResponse’ from SFDC and set as attachment in the message log.
14. After the integration flow is deployed, the message can be monitored in ‘Overview’ section.
queryResponse payload set as attachment as per groovy script in step-13.
SFDC loginResponse set in message log-
SFDC queryResponse set in message log-
15. The query response of SFDC can be verified by performing the same query operation in SFDC-
This blog can be used as an idea for performing more complicated operations with SFDC involving complicated mappings.
Probably steps will be much simpler using SFDC adapters in SAP_CPI.
You can refer to one of the third party SFDC adapter provided by Advantco in the link – https://www.advantco.com/product/adapter/sfdc-hci
Thank you for sharing.
This is quite insightful.