Liferay 7 Salesforce.com Gogo Shell Command Client

Ci spiace, ma questo articolo è disponibile soltanto in Inglese Americano. Per ragioni di convenienza del visitatore, il contenuto è mostrato sotto nella lingua alternativa. Puoi cliccare sul link per cambiare la lingua attiva.

This project is born as demo for using the Salesforce SOAP API Client OSGi Bundle inside of the Liferay 7. This sample project implements a set of Gogo Shell commands that allow us to interact with the Salesforce CRM system. All project sources code are available on GitHub (salesforce-client-gogoshell-command).

The Force.com SOAP API (formerly known as the Force.com Web Services API) lets you integrate Force.com applications that can create, retrieve, update or delete records managed by Salesforce, Force.com, and Database.com, records such as accounts, leads, and custom objects. With more than 20 different calls, SOAP API also lets you to maintain passwords, perform searches, and much more. You can use the SOAP API with any programming language that supports Web services.

Figure 1 – Manage data using the Force.com SOAP API

 

The commands that are implemented in Liferay 7:

  1. salesforce:login: Login to your Salesforce instance
  2. salesforce:createAccount: Create account into your Salesforce instance
  3. salesforce:getNewestAccount: Query for the newest accounts

The diagram in Figure 2 shows a possible integration scenario between Liferay and the CRM system that in this case is Salesforce.com. The CRM Application (Figure 2) in this case is implemented by this project.

Integration scenario Liferay 7 and CRM (in this case Salesforce.com) via SOAP

Figure 2 – Integration scenario Liferay 7 and CRM (in this case Salesforce.com) via SOAP

The version of this project was tested on Liferay 7 CE GA4. You can download the tomcat bundle of the Liferay 7 CE GA4 from sourceforge.

1. Getting started

To build the project you need:

  1. Sun/Oracle JDK 1.8
  2. Maven 3.2 or Gradle 3.x (this project include the gradle wrapper)
  3. Git tools

You also need to install the OSGi Salesforce SOAP API client bundle. You can follow these instructions How to install in Liferay 7 CE/DXP. If you want can download the bundle JAR salesforce-client-soap (v1.0.1) from Maven repository and deploy to Liferay (via auto deploy directory or directly in $LIFERAY_HOME/osgi/modules);

To start testing the plugin you need:

  1. clone this repository
  2. build project (with Maven or Gradle)
  3. deploy OSGi module (salesforce-client-gogoshell-command-$version.jar) to Liferay instance

From your terminal execute the commands:

if use Maven then run this command:

if use gradle wrapper (gradlew) then run this command:

The last commands create a OSGi bundle and deploy directly on your Liferay instance. The deployment directory is set by the property liferay.home for Maven (defined inside the pom.xml), while for Gradle is set by the property auto.deploy.dir(inside the gradle.properties).

The default value for the two properties:

  1. liferay.home /opt/liferay-ce-portal-7.0-ga4
  2. auto.deploy.dir /opt/liferay-ce-portal-7.0-ga4/deploy

If you want could customize the deployment directory in this two way (Maven or Gradle):

Check if the bundles are installed correctly via Gogo Shell.

Both bundles are installed correctly.

2. Gogo Shell Command in action on Liferay 7

Bundles are installed correctly, so we can begin to see how to use commands. The commands that are implemented:

  1. salesforce:login: Login to your Salesforce instance
  2. salesforce:createAccount: Create account into your Salesforce instance
  3. salesforce:getNewestAccount: Query for the newest accounts

To verify the commands that are available it is possible to execute the command (via Gogo Shell) help | grep salesforceand obtain the following result.

You can display online help for each command typing (on Gogo Shell) help $scope:$command and obtain the following result (for salesforce:login):

Console 1 – Output of the command help:salesforce:login

Now let’s see the commands in action (in the order shown above).

Console 2 – Try login to Salesforce.com (password is fake)

Console 3 – Result of the login operation

Console 4 – Get the last newest five accounts

Console 5 – Result of the salesforce:getNewestAccount operation

Console 6 – Start the interactive account creation process

Console 7 – Result of the salesforce:createAccount operation

Console 8 – Get the last one newest accounts

Console 9 – Result of the salesforce:getNewestAccount

The SalesforceClientCommand OSGi component is linked to the SalesforceClientCommandConfiguration configuration (via configurationPid attribute).

Java Code 1 – Definition of the OSGi component implementing the commands.

Figure 3 shows the configuration parameters used by the Gogo Shell commands. As you can see from the configuration, communication tracking between Liferay and Salesforce is enabled. Each SOAP request and response flow is traced to the configured file.

Salesforce Client Gogo Shell Command OSGi Configuration

Figure 3 – Salesforce Client Gogo Shell Command OSGi Configuration

 

XML Code 1 – SOAP Request for the salesforce:getNewestAccount operation

XML Code 2 – SOAP Response for the salesforce:getNewestAccount operation

Resources on Salesforce

If you follow this resources you could see how to use Salesforce SOAP API.

  1. Introducing SOAP API
  2. Cheat Sheets
  3. Force.com SOAP API Cheatsheet
  4. Force.com Web Service Connector (WSC)

I leave you with the link to the demo video showing the Gogo Shell commands in action. Let me know your considerations that are very important to me.

Video 1 – Liferay 7: Demo Salesforce Gogo Shell Command

1 Condivisioni