Salesforce Inbound Endpoint Example¶
The Salesforce streaming Inbound Endpoint allows you to perform various operations on Salesforce streaming data.
The Salesforce Streaming API receives notifications based on the changes that happen to Salesforce data with respect to a SOQL (Salesforce Object Query Language) query you define, in a secured and scalable way. For more information, go to the Quick Start Using Workbench documentation.
What you'll build¶
The Salesforce inbound endpoint is a listening inbound endpoint that can consume messages from Salesforce. This injects messages into an integration sequence. However, for simplicity of this example, you will only log the message. You can extend the sample as required using mediators in WSO2 Micro Integrator.
In this example, we can trigger the notifications to the Salesforce Inbound Endpoint via creating the Platform events
or PushTopic
methods. Please note that our example configurations are based on creating the PushTopic
method. You can use the instructions given in the Setting up the PushTopic in Salesforce documentation.
The following diagram illustrates all the required functionality of the Salesforce inbound operations that you are going to build.
For example, we are building an integrated example driven through the Salesforce connector and Salesforce Inbound Endpoint. The user calls the Salesforce REST API. It invokes the create sequence and creates a new account in Salesforce. Then, through the retrieve sequence, it displays all the existing account details to the user.
Now that you have configured the Salesforce Inbound Endpoint, use the following Inbound Endpoint configuration to retrieve account details from your Salesforce account. The Salesforce inbound endpoint acts as a message receiver. You can inject that message into the mediation flow to get the required output.
Configure inbound endpoint using WSO2 Micro Integrator Visual Studio Code extension¶
-
Follow the steps in create integration project guide to set up the Integration Project.
-
First, let's create a sequence to process the message. In this example, for simplicity, you will only log the message, but in a real-world use case, this can be any type of message mediation. Select Micro Integrator and click on
+
in Sequences to create the sequence. Add a log and drop the mediator to the sequence. The source view of the sequence will look like below.<?xml version="1.0" encoding="UTF-8"?> <sequence name="test" onError="fault" xmlns="http://ws.apache.org/ns/synapse"> <log level="full"/> <drop/> </sequence>
-
Now let's create the Salesforce Inbound Endpoint. Click on
+
in Inbound Endpoints and select Salesforce to create the Salesforce Inbound Endpoint. -
Provide the following details in the form that opens.
- Name:
SalesforceInboundEP
- Automatically generate sequences: deselect
- Injecting Sequence Name:
test
- Error Sequence Name:
test
- Polling Interval:
100
- Execute sequentially: select
- Coordination: select
- Salesforce Object:
/topic/Account
- Package Version:
37.0
- User Name:
- Password:
- Login Endpoint:
https://login.salesforce.com
- SOAP API Version:
22.0
- Connection Timeout:
20000
- Wait Time:
5000
- Replay: deselect
- Event ID File Path:
<FILE_PATH>
- Name:
-
Click on Submit to complete the inbound endpoint creation. The Salesforce Inbound Endpoint will be created and listed in the Inbound Endpoints section.
<?xml version="1.0" encoding="UTF-8"?>
<inboundEndpoint name="SalesforceInboundEP" class="org.wso2.carbon.inbound.salesforce.poll.SalesforceStreamData" onError="test" sequence="test" suspend="false" xmlns="http://ws.apache.org/ns/synapse">
<parameters>
<parameter name="coordination">true</parameter>
<parameter name="sequential">true</parameter>
<parameter name="interval">100</parameter>
<parameter name="inbound.behavior">polling</parameter>
<parameter name="connection.salesforce.replay">false</parameter>
<parameter name="connection.salesforce.EventIDStoredFilePath"><FILE_PATH></parameter>
<parameter name="connection.salesforce.packageVersion">37</parameter>
<parameter name="connection.salesforce.salesforceObject">/topic/Account</parameter>
<parameter name="connection.salesforce.loginEndpoint">https://login.salesforce.com</parameter>
<parameter name="connection.salesforce.userName"><USERNAME></parameter>
<parameter name="connection.salesforce.password"><PASSWORD></parameter>
<parameter name="connection.salesforce.waitTime">5000</parameter>
<parameter name="connection.salesforce.connectionTimeout">20000</parameter>
<parameter name="connection.salesforce.soapApiVersion">22.0</parameter>
</parameters>
</inboundEndpoint>
Note: To configure the
connection.salesforce.password
parameter value, please use the steps given under the topicReset Security Token
in the Salesforce inbound endpoint configuration document.
Export integration logic as a CApp¶
In order to export the project, refer to the build and export the carbon application guide.
Deployment¶
-
Go to the WSO2 Connector Store.
-
Download the Salesforce inbound endpoint JAR file.
-
Copy this JAR file to the
<MI_HOME>/lib
folder. -
Copy the exported carbon application to the
<MI_HOME>/repository/deployment/server/carbonapps
folder. -
Start the integration server.
Test¶
Note: If you want to test this scenario by inserting data manually into the created object records, see Testing the PushTopic Channel.
Please use the Salesforce REST Connector example testing steps to test this Inbound Endpoint scenario;
Save a file called data.json
with the following payload (change the value of the Name
field to Manager
).
{
"sObject":"Account",
"fieldAndValue": {
"name": "Manager",
"description":"This Account belongs to WSO2"
}
}
curl -X POST -d @data.json http://localhost:8280/salesforcerest --header "Content-Type:application/json"
Expected response
To: , MessageID: urn:uuid:2D8F9AFA30E66278831587368713372, Direction: request, Payload: {"event":{"createdDate":"2020-04-20T07:45:12.686Z","replayId":4,"type":"created"},"sobject":{"Id":"0012x0000048j9mAAA","Name":"Manager"}}
What's next¶
- You can deploy and run your project using different Micro Integrator installation options.
- To customize this example for your own scenario, see Salesforce Inbound Endpoint Reference documentation for all operation details of the connector.