Salesforce
Camel Salesforce Component
The easiest way to integrate Salesforce with PFX is using Apache Camel Component. This component supports producer and consumer endpoints to communicate with Salesforce using Java DTOs. There is a companion Maven plugin Camel Salesforce Plugin that generates these DTOs (see further below). The component completely handles OAuth 2 authentication for REST requests and supports various Salesforce APIs. For details see Apache Camel Salesforce component documentation.
Example
The following example shows a specific customer price list integration:
Adding depenencies:
Dependency in pom.xml
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-salesforce</artifactId>
<version>${version.camel}</version>
</dependency>
Â
Adding Camel Salesforce Plugin that generates these DTOs. You can include multiple SFDC objects to generate DTOs for them:
Camel Salesforce Plugin
<plugin>
<groupId>org.apache.camel.maven</groupId>
<artifactId>camel-salesforce-maven-plugin</artifactId>
<version>${version.camel}</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<clientId>${salesforce.clientId}</clientId>
<clientSecret>${salesforce.clientSecret}</clientSecret>
<userName>${salesforce.userName}</userName>
<password>${salesforce.password}</password>
<loginUrl>${salesforce.loginUrl}</loginUrl>
<packageName>net.pricefx.integration.salesforce.dto</packageName>
<includes>
<include>Price_List__c</include>
</includes>
</configuration>
</plugin>
Â
Component bean configuration:
<bean id="salesforce" class="org.apache.camel.component.salesforce.SalesforceComponent">
<property name="loginConfig">
<bean class="org.apache.camel.component.salesforce.SalesforceLoginConfig">
<property name="loginUrl" value="${salesforce.loginUrl}"></property>
<property name="userName" value="${salesforce.userName}"></property>
<property name="password" value="${salesforce.password}"></property>
<property name="clientId" value="${salesforce.clientId}"></property>
<property name="clientSecret" value="${salesforce.clientSecret}"></property>
</bean>
</property>
<property name="packages" value="${salesforce.packageName}"></property>
</bean>
Â
Code snippet from the processor for creating Java DTO:
Â
Sending the data:
Log in Using SOAP API
In some cases, you may be asked to authenticate REST requests via a Session ID. Then you cannot use the Camel Salesforce component as it uses the OAuth 2 authentication. To get the Session ID, you need to use the Salesforce SOAP API.
SOAP API Session ID request:
Salesforce returns an XML response which includes the <sessionId> and <serverUrl> elements.
The session ID needs to be set on the "Authorization" header:
IntegrationManager version 5.8.0