Troubleshooting SAP-PI and Salesforce.com integration scenario
Troubleshooting SAP-PI and Salesforce.com integration scenario: Salesforce.com offers technology solution which support CRM of an organization. In addition to the web interface, salesforce.com offers a SOAP/REST Web service API that enables integration with other systems. SAP-PI uses SOAP  to interact with Salesforce.com. This article does not intend to build up SAP-PI and Salesforce.com integration scenario. In case you need details on how to set up exchange of messages between SAP-PI and Salesforce.com then please refer to points  and  in reference section.
After a scenario is built in SAP-PI to communicate with Salesforce.com then comes the responsibility of maintaining such connection. Periodically there are refresh happening in Salesforce Sandbox database to bring it in sync with production Salesforce database. After such refresh there might be problems for SAP-PI to connect or communicate with Salesforce.com using SOAP receiver adapter. This article describes SOAP faults while SAP-PI is trying to communicate with Salesforce.com and possible steps to resolve the errors. I am just sharing my experiences with SCN , the various trouble shooting I had to perform for maintenance of SAP-PI and SFDC(salesforce.com) integration scenario. If you feel this this article is helpful then all credits goes to my team members who have always provided me unending help and support.
SAP-PI integrates Salesforce.com (SFDC) with SAP-ISU. The manner is explained in this figure below
In most of the projects there will be development, acceptance and production servers. SAP-PI development and acceptance server would connect to Sandbox URL of Salesforce.com whereas production server will connect to different URL. Salesforce gives us the ability to create multiple copies of our organization in separate environments for a variety of purposes, such as testing and training, without compromising the data and applications in our Salesforce production organization. These copies are called sandboxes and are nearly identical to our Salesforce production organization.
Sandboxes are completely isolated from Salesforce production organization, so operations performed in sandboxes do not affect the Salesforce production organization, and vice versa. The URL to which PI server connects to production environment is different from the URL used to connect to sandbox server. After some definite intervals of time production data instance is copied into sandbox data instance. This is done to provide more realistic data for test environment in development system. Salesforce stores sandbox organizations on several instances. When a sandbox is created or refreshed, an instance is selected for the sandbox, so our sandbox may appear on different instances and have different URLs. This article mainly tends to describe problems SAP-PI might face after a refresh and how to resolve them.
The sequence of events that happen while SAP-PI tries to communicate with Salesforce and do a simple query on contacts object (for example) is as shown below.
After sandbox refresh in development environment of SFDC the SOAP fault message during login is as shown below
<? xml version="1.0" encoding="UTF-8" standalone="yes" ?> Application APPLICATION_ERROR application fault LoginFault M
In SXMB_MONI error symbols like this may be obtained.
- Need to login to Salesforce.com sandbox server as administrator, then need to go to Setup -> App set up -> Develop –> API -> Generate Enterprise WSDL àgenerate
as shown below
The WSDL will be in form of XML. At the end of the WSDL tag “service” can be seen.
Here a sample service tag is being shown.
Sforce SOAP API
The important part of service tag is the portion “soap: address”. The URL to the Salesforce server is obtained in “location” attribute. This URL has to be in target URL of SOAP receiver adapter meant for logging in to salesforce.com.
N.B- In case of Sandbox database refresh message structure is not expected to change. Thus there is no need to re-import the enterprise WSDL in SAP-PI server and redo all mappings again
After the target URL for Login has been changed. Then SAP-PI tries to make a query to Contacts object within SFDC. The manner in which request was made prior to SFDC refresh is shown below
<? xml version="1.0" encoding="utf-8" ?> 2TjsllIJRC_3Uvo.ZLLEWb9ed7igHX2aarxpWzrgUeOJWh1AwrqnR.ZwvbKa0Gb8ueHy Select Id, HasOptedOutOfEmail FROM Contact
The response to this message was a SOAP fault message as shown here
XIAdapter ADAPTER.HTTP_EXCEPTION HTTP 500 Internal Server Error M
In the response message payloads main attachment this XML message was shown
sf:INVALID_SESSION_ID INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session INVALID_SESSION_ID Invalid Session ID found in SessionHeader: Illegal Session
This error is quite misleading as the session ID supplied is a valid one. Thus the error message may not be showing the exact reason of SOAP Fault. Install the SOAPUI tool in local system  . Import the latest enterprise WSDL into the SOAP UI tool and set up proxy server details if any. This is because this helps to find out the exact structure of the SOAP message being accepted by Salesforce.com after sandbox refresh activity. There cannot be any change in number of tags or name of tags in SOAP message. Thus changes might be in namespace information. This has to be identified.
Go to file ànew Soap UI project à give a project name and import WSDL in form of XML file. The XML file can be formed by saving the generated WSDL file.Under each project there will be operations such as login, logout ,query etc. Right click on query and generate new instance of query. You might need to delete excess fields to create the exact message structure as per query structure in SAP-PI. Thus after modification contact query in SOAP UI tool was looking something like this
If noted carefully the message structure shown above the default namespace is “urn:enterprise.soap.sforce.com” and tag “SessionHeader” is identified by same default namespace. Thus on comparison with first xml message shown under problem 2 , the namespace information is different for “SessionHeader” as there is no namespace information attached to it.Using java or XSLT mapping the namespace information has to be added.
Following is the change in message namespace information before and after SFDC sandbox refresh.
After SFDC sandbox refresh new SOAP header with default namespace information it becomes as shown below
This resolves the problem due to slight change in default namespace. Once correct SOAP message from SAP-PI is sent the SOAP fault is avoided.
There might be SOAP faults even after this corrections as shown below
sf:INVALID_FIELD INVALID_FIELD: Description, CurrencyIsoCode, OwnerId, HasOptedOutOfEmail, CreatedDate ^ ERROR at Row:1:Column:380 No such column 'HasOptedOutOfEmail' on entity 'Contact'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names. INVALID_FIELD Description, CurrencyIsoCode, OwnerId, HasOptedOutOfEmail, CreatedDate ^ ERROR at Row:1:Column:380 No such column 'HasOptedOutOfEmail' on entity 'Contact'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names. 1 380
The fault string says that a particular field “HasOptedOutOfEmail” is an invalid. Now this used to be valid field earlier. In this case the user ID with which SAP-PI is accessing Salesforce.com may not have field level access permission. The permission has to be given from Salesforce team.
You might receive a SOAP fault with following message
sf:INVALID_OPERATION_WITH_EXPIRED_PASSWORD INVALID_OPERATION_WITH_EXPIRED_PASSWORD: The users password has expired, you must call SetPassword before attempting any other API operations INVALID_OPERATION_WITH_EXPIRED_PASSWORD The users password has expired, you must call SetPassword before attempting any other API operations
Every time SAP-PI tries to login to SFDC server it has to login using a user credential.
The user credential has login id and password. This issue was reported for production server. While checking development environment SAP-PI server which is connected to Salesforce.com sandbox environment it was found same SOAP fault is being observed here too. The Salesforce team reset the password for same user in Sandbox system and set it to “Password Never Expires” capability. After resetting the user password in sandbox followed by changes in development SAP-PI server, the production SAP-PI server also stopped giving errors. I have no clues if the user credentials in sandbox environment have any logical connection to production environment of Salesforce.com but at least it resolved the error in production SAP-PI too.
You might receive error message as shown below
XIAdapterFramework GENERAL com.sap.aii.af.ra.ms.api.DeliveryException: unable to create a socket M
Solution: We always connect to Salesforce server from specific protected network. Thus all SOAP request has to pass through proxy server. If the proxy server does not allow the SOAP request to flow through you will receive errors as shown above. This is either due to the fact that proxy server details mentioned in SOAP receiver communication channel is not correct, authentication error etc. In this case you need to consult the network team to resolve the issue.
You might get an error message like this as shown below
XIServer PL_TIMEOUT Timeout condition of pipeline reached N
Solution: – SAP-BASIS team restarted the java stack of the PI server and the error is gone.
After all troubleshooting again you are getting the same error “login Fault” as shown in problem 1
Solution: Every time SAP-PI tries to login to SFDC server it has to login using a user credential. The user credential has login id and password which is fixed. The business has to register with salesforce.com for its services. After a definite period of time the registration has to be renewed. Thus check with salesforce.com team if the business has to re-register with salesforce.com or not. The exact cause of such fault will be shown to you if you try logging in to salesforce.com using the login credentials directly and not through SAP-PI
After all troubleshooting again you are getting the same error “Invalid Session ID found in SessionHeader: Illegal Session” as shown in problem 2
Solution: Every time SAP-PI tries to login to SFDC server it has to login using a user credential. The user credential has login id and password which is fixed. Say for example you are using credentials to login to salesforce.com through SAP-PI. Thus the SOAP login request to SFDC carries the name . Now while SAP-PI is trying to connect to Salesforce.com at the time the user is trying to login to salesforce.com directly, then it’s possible you can receive this error. Thus you need to ensure that login credential used by SAP-PI to login to Salesforce.com is not used to login to salesforce.com directly.
2. 2. https://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/50a76cfa-4966-2d10-aba7-da496d9b5bcf
Would you like to access Full Article?
If you are already a member in this website, Please Click here to loginIf you are not yet a member, Please Click here to Sign up
New NetWeaver Information at SAP.com