다음을 통해 공유


Logic App: Salesforce Integration using SOAP Version API

Introduction

In this article, I would like to walk through a typical Salesforce scenario using Logic App. The scenario is, a notification will be sent to Logic App from Salesforce System when there is an opportunity updated with ‘Closed Won’ stage.

In this sample, I have used SOAP API so it required to have a Function App for the conversion of XML to JSON. Salesforce Rest API based connectors are available in Logic app which requires no coding or conversion.

Scenario

  • A sales representative creates an “opportunity” in the Salesforce system.
  • When the status of the opportunity is set to “Closed Won”, a notification is sent to Logic app.
  • Logic App uses the information received from Salesforce to create a purchase order entry in an in-house SQL Server database table.

Before we start the logic app we need to setup Source(Salesforce) and Destination(SQL Server On-Premise) Systems.

Salesforce Setup

  • Provide our Http URL to Salesforce so that it will post Messages whenever the condition is met.
  • Salesforce SOAP Message would look like,

https://howtobiztalk.files.wordpress.com/2017/02/9.png?w=720

SQL Setup On-Premise

Once we receive the request, we split the Opportunities to the below stored procedure which inserts a row local on-premise table.

https://howtobiztalk.files.wordpress.com/2017/02/2.png?w=720

On-Premise Data Gateway

Once we create the table in the on-premise database, install the “on-premises data gateway” and configure it.

here is an article could help you to setup with "on-premises data gateway".

Logic App

https://howtobiztalk.files.wordpress.com/2017/02/11.png?w=720

This logic app receives the notification, converts into Json message and then it calls the on-premise stored procedure for each notification.

Once we receive the notification, I use an Azure function which removes the namespace of the received SOAP message and converts into JSON formatted message. Below is my function app call. 

https://howtobiztalk.files.wordpress.com/2017/02/12.png?w=720

Function App 

https://howtobiztalk.files.wordpress.com/2017/02/13.png?w=720

After receiving the JSON request from Logic App, out function app fetches the XML part and removes all the namespace out of it. Then the plain XML part is being converted into JSON formatted message and sent back to Logic App.After receiving the JSON format from XMLTOJson function app, using parse JSON shape, I am creating a JSON request.

https://howtobiztalk.files.wordpress.com/2017/02/14.png?w=720

Now we need to loop through notification request message and call on-premise stored procedure to insert the data into On-premise table.

https://howtobiztalk.files.wordpress.com/2017/02/15.png?w=720

In the code view it would look like the below(the below view is from Chrome json editor,

To run this program we could use Postman, also once all done this Logic app we could update any opportunity in Salesforce as “Closed Won” stage, so that a notification will be sent to Logic App.

https://howtobiztalk.files.wordpress.com/2017/02/16.png?w=720

Successful Run,

https://howtobiztalk.files.wordpress.com/2017/02/17.png?w=720

If your stored procedure is not reachable then try restarting your “On-premises data gateway service”service in your local machine and start connecting through “On-premises data gateway” UI.

Here is my Salesforce data in Customer table on-premise.

https://howtobiztalk.files.wordpress.com/2017/02/18.png?w=720