Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Salesforce Integration With MuleSoft Salesforce Connector

DZone's Guide to

Salesforce Integration With MuleSoft Salesforce Connector

Learn how to integrate Salesforce with the Mulesoft Salesforce connector.

· Integration Zone
Free Resource

Build APIs from SQL and NoSQL or Salesforce data sources in seconds. Read the Creating REST APIs white paper, brought to you in partnership with CA Technologies.

Enterprises are using multiple applications, but most of them are not designed well enough to work with one another. Integration of different apps helps achieve greater value on operational consistency, efficiency, and quality of the organization. 

Salesforce is presumably the leading CRM software and enterprise cloud ecosystem in the world today. Having a wide range of consumers and with the nature of this platform, it's certain to be a target of integration.

This blog post will explore how to integrate with salesforce using MuleSoft salesforce connector.

Setup/Installation - Assuming you have knowledge of MuleSoft connectors and Anypoint studio, I'll provide the steps for installing the Salesforce connector.

In this how-to, we use:

  • Anypoint Studio - 5.4.2 with Mule ESB Runtime 3.7.3
  • Salesforce developer account - Sign up for one at Salesforce. Then get your Security following these steps: Login to salesforce, then click Setup > My Personal Information >  Reset Security Token. Then, click Reset My Security Token
  • Maven - version 3.x.x

Step 1: Download and install the latest Salesforce connector plugin.

  1. Open Anypoint Studio click menu Help > Install New Software
  2. In work with: select the Anypoint connector update site.
  3. Select the latest Salesforce version. The current version is 7.0.1

Image title

Step 2: Namespace and SchemaLocation

<mule xmlns="http://www.mulesoft.org/schema/mule/core"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:sfdc="http://www.mulesoft.org/schema/mule/sfdc"
      xsi:schemaLocation="
               http://www.mulesoft.org/schema/mule/core
               http://www.mulesoft.org/schema/mule/core/current/mule.xsd
               http://www.mulesoft.org/schema/mule/sfdc
               http://www.mulesoft.org/schema/mule/sfdc/current/mule-sfdc.xsd">

      <!-- Insert your configuration elements and your flow here -->
</mule>

Step 3: Maven Dependencies

  1. Add to pom.xml file.
    <repositories>
       <repository>
            <id>mule-ee-releases</id>
            <name>MuleEE Releases Repository</name>
            <url>https://repository-master.mulesoft.org/nexus/content/repositories/releases-ee/</url>
        <repository>
            <id>mule-ee-snapshots</id>
            <name>MuleEE Snapshots Repository</name>
            <url>https://repository-master.mulesoft.org/nexus/content/repositories/ci-snapshots/</url>
        </repository>
    </repositories>
  2. Add the module as a dependency.
    <dependency>
        <groupId>org.mule.modules</groupId>
        <artifactId>mule-module-sfdc</artifactId>
        <version>RELEASE</version>
    </dependency>
  3. Include it in the packaging process.
    <plugin>
    <groupId>org.mule.tools.maven</groupId>
    <artifactId>mule-app-maven-plugin</artifactId>
    <version>${mule.tools.version}</version>
    <extensions>true</extensions>
    <configuration>
    <copyToAppsDirectory>true</copyToAppsDirectory>
    <applications>
    <application>src/main/app/subfolder/</application>
    </applications>
    <inclusions>
    <inclusion>
    <groupId>org.mule.modules</groupId>
    <artifactId>mule-module-sfdc</artifactId>
    </inclusion>
    <inclusion>
    <groupId>org.mule.modules</groupId>
    <artifactId>mule-module-objectstore</artifactId>
    </inclusion>
    </inclusions>
    </configuration>
    </plugin>

Now that we're done installing salesforce connector in MuleSoft Anypoint Studio, we can proceed to the next steps, creating integration flows.

Security Integration

Security is a basic requirement for any enterprise applications, it prevents unauthorized access, use, and destruction of resources and sensitive information.

Part I: Connect to Salesforce with basic authentication.

Our primary objective is to connect with Salesforce using basic authentication.

1. Create a simple flow with HTTP listener, then invoke Salesforce server timestamp.

Image title

How do you use Gist in DZone?? https://gist.github.com/vinzonwsl/aebe066593bf00ff378a

2. Configure Salesforce connector with basic authentication. Provide the username, password, and security token. The security token is emailed to you when you click the reset security token from your Salesforce/Salesforce developer account.

Image title

3. After successful validation of the configuration, proceed to test the application by invoking the HTTP endpoint using postman or any client you're used to, like soapui or plain browsers.

Image title

As a result, we can see a simple integration between MuleSoft and Salesforce with basic authentication. In the second part, we'll be having the same flow, using authorization OAuth 2.0 JWT Bearer.

The Integration Zone is brought to you in partnership with CA Technologies.  Use CA Live API Creator to quickly create complete application backends, with secure APIs and robust application logic, in an easy to use interface.

Topics:
mulesoft ,salesforce ,connectors

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}