Integration Using SAP PI: A Case Study
Integration Using SAP PI: A Case Study
Applies to:
SAP NetWeaver Process Integration 7.1. For more information, visit the Service Bus-based Integration homepage.
Summary
This article explains step by step procedure to integrate SAP PI with Salesforce.com (SFDC) using the enterprise WSDL. Author: Prasanna Vittal
Author Bio
Prasanna Vittal is currently working for Wipro Technologies as an SAP XI/PI Consultant. He has over 3.5 years of experience in SAP Integration Technologies viz. SAP XI/PI and SAP MII.
Table of Contents
Introduction ......................................................................................................................................................... 3 Overview ............................................................................................................................................................. 3 Step by Step Execution ...................................................................................................................................... 4 Create developer account in SFDC ................................................................................................................ 4 Download the Enterprise WSDL ..................................................................................................................... 4 Testing the WSDL using SOAPUI ................................................................................................................... 4 Implementation Using SAP PI 7.1 ................................................................................................................... 6
Design Steps................................................................................................................................................................ 6 Configuration Steps ................................................................................................................................................... 12 Testing the Interface .................................................................................................................................................. 16
Introduction
In our current project, the client has decided to replace SAP CRM with Salesforce.com (SFDC Online CRM). We are doing a POC to integrate SFDC with SAP ECC using SAP XI. I would like to thank Bhavesh Kantilal, Saravana Kuppusamy, Harsh, Santhosh, Unnamalai and Pragya for helping me out during the implementation of this Proof of Concept.
Overview
Salesforce.com (SFDC) is a Software as a Service (SaaS) company that distributes business software on a subscription basis. It is best known for its Customer Relationship management (CRM) products. This article explains various steps involved in the integration of SFDC with SAP ECC using SAP PI 7.1. SFDC exposes a web services interface that can be accessed using an Enterprise WSDL. Some of the web services are Create Account, Update/Upsert/Delete Account, Query Account Details etc., In the article, I will show how to call a simple SFDC web service - getServerTimestamp, which when called, gives the server timestamp as response. Once we achieve this, we can implement any of the web service that SFDC offers, with some modifications to the WSDL file.
Once we receive the Session ID and Server URL, we have to set them in the header of getServerTimestamp web service and get the Servers timestamp as response. Below is the screenshot for the same.
Implementation Using SAP PI 7.1 Now, we will implement the same using SAP PI 7.1. Design Steps Below are the design steps that we need to perform in the Enterprise Service Repository: Create the namespace and import the Enterprise WSDL as an external definition.
Create an Outbound Synchronous Service Interface. Assign the External Definitions loginRequest as the Output message.
Similarly, assign getServerTimestampResponse from the external definition, as the input message.
Create an Inbound Synchronous Service Interface. Assign the External Definitions getServerTimestampRequest as the Output message and getServerTimestampResponse as the input message, as shown in the above screenshot.
Create a message mapping. Load the loginRequest at the Source side and getServerTimestampRequest at the target side.
Create a UDF (SampleUDF1) and use Dynamic Configuration to set the parameter TServerLocation with the Server URL that we received in the response message of the login web service. We found out that this Server URL is always constant, so we have manually set this in the UDF. We can assign this UDF to any node in the target.
We will create a Java Mapping Program to obtain session ID and server URL by doing a SOAP lookup, and set these fields in the SOAP Envelope. Create a new Java Mapping Class using SAP NetWeaver Developer Studio. We will use the DOM parser to parse the SOAP response. In the execute() method, we will call two functions. In the first one, we will pass the username and password (password+security token, without +) to the SOAP lookup API to login to the SFDC and get the Session ID. For details regarding SOAP Lookup, refer to Bhaveshs Blog in the Related Articles section. In the second function, we will add the SOAP Envelope to the incoming payload and set the sessionId field in the SOAP Header. For the complete Code, refer to uarunas wiki page. You can also find this link under Related Contents section, at the end of this article.
Export the Java Class as a .JAR file and import it into the ESR under Imported Archives.
Create an Operation Mapping and use the Message mapping and Java mapping in sequence.
Configuration Steps Below are the configuration steps that we need to perform in the Integration Directory: Create Business Components for the Sender ECC system and SFDC Receiver. Create a Receiver SOAP Communication Channel (Channel1). Since this channel will be used in the SOAP lookup, it should not be associated with any Receiver Agreement. In this channel, we provide the Target URL (https://www.salesforce.com/services/Soap/c/18.0) and SOAP Action (login).
Create another Receiver SOAP Communication Channel (Channel2). Settings will be as follows: o o Provide Target URL (it will be over written by the Dynamic Configuration). Check Use Adapter-Specific Message Attributes and Variable Transport Binding, since we are setting the TServerLocation attribute using Dynamic Configuration within the UDF.
o o
Under Conversion Parameters, check Do Not Use SOAP Envelope, as we are manually building the SOAP Envelope, to set the fields in the SOAP Header. Provide the SOAP Action (getServerTimestamp).
Since we are using the SOAP Adapter with option Do Not Use SOAP Envelope, the content type of the incoming message will be application/xml. We need to change it to text/xml. To achieve this, we need to use the adapter module MessageTransformBean before the XISOAPAdapterBean and set the parameter Transform.ContentType to text/xml.
Create Receiver Determination and Interface Determination with ECC System as the sender and Business Component for SFDC as the receiver. In the Interface Determination, use the Operation Mapping and Inbound Interface that we created in ESR. Create a Receiver Agreement and provide the Communication Channel (Channel2).
Testing the Interface Steps to be followed for testing this interface are as follows: 1. We can trigger this interface from the sender ECC system in two ways. a. ABAP Proxy b. RFC Call. (For testing purpose, we can even use Runtime Workbenchs test too l or an HTTP Client) 2. We dont have to pass any values in the source message, as we are directly passing the credentials in the java Mapping. Below is a screenshot of RWBs test tool.
4. After the SOAP lookup, this is how the message looks like:
Related Content
1) Java Mapping Program Wiki by uaruna http://wiki.sdn.sap.com/wiki/display/XI/SFDC+Integration+using+PI+7.1++How+to+add+SOAP+Envelope+in+Java+Mapping 2) SOAP Lookup Bhaveshs Blog http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/5001