VOOZH about

URL: https://www.cdata.com/kb/tech/db2-odata-salesforce-lightning-connect.rst

⇱ Edit and Search DB2 External Objects in Salesforce Connect (API Server)


Edit and Search DB2 External Objects in Salesforce Connect (API Server)

πŸ‘ Jerod Johnson
Jerod Johnson
Director, Technology Evangelism
Use the API Server to securely provide OData feeds of DB2 data to smart devices and cloud-based applications. Use the API Server and Salesforce Connect to create DB2 objects that you can access from apps and the dashboard.

The CData API Server enables you to access DB2 data from cloud-based applications like the Salesforce console and mobile applications like the Salesforce1 Mobile App. In this article, you will use the API Server and Salesforce Connect to access DB2 external objects alongside standard Salesforce objects.

Set Up the API Server

If you have not already done so, download the CData API Server. Once you have installed the API Server, follow the steps below to begin producing secure DB2 OData services:

Connect to DB2

To work with DB2 data from Salesforce Connect, we start by creating and configuring a DB2 connection. Follow the steps below to configure the API Server to connect to DB2 data:

  1. First, navigate to the Connections page.
  2. Click Add Connection and then search for and select the DB2 connection. πŸ‘ Selecting a data source (SQLite is shown)
  3. Enter the necessary authentication properties to connect to DB2.

    Set the following properties to connect to DB2:

    • Server: Set this to the name of the server running DB2.
    • Port: Set this to the port the DB2 server is listening on.
    • Database: Set this to the name of the DB2 database.
    • User: Set this to the username of a user allowed to access the database.
    • Password: Set this to the password of a user allowed to access the database.

    You will also need to install the corresponding DB2 driver:

    • Windows: Install the IBM Data Server Provider for .NET.

      On Windows, installing the IBM Data Server Provider is sufficient, as the installation registers it in the machine.config.

    • Java: Install the IBM Data Server Driver for JDBC.

      In the Java version, place the IBM Data Server Driver JAR in the www\WEB-INF\lib\ folder for this application.

    πŸ‘ Connecting to a datasource (SQLite is shown)
  4. After configuring the connection, click Save & Test to confirm a successful connection.

Configure API Server Users

Next, create a user to access your DB2 data through the API Server. You can add and configure users on the Users page. Follow the steps below to configure and create a user:

  1. On the Users page, click Add User to open the Add User dialog.
  2. Next, set the Role, Username, and Privileges properties and then click Add User. πŸ‘ Configure a new user
  3. An Authtoken is then generated for the user. You can find the Authtoken and other information for each user on the Users page: πŸ‘ API Server user settings

Creating API Endpoints for DB2

Having created a user, you are ready to create API endpoints for the DB2 tables:

  1. First, navigate to the API page and then click Add Table . πŸ‘ Add tables
  2. Select the connection you wish to access and click Next. πŸ‘ Select the connection (SQLite is shown)
  3. With the connection selected, create endpoints by selecting each table and then clicking Confirm. πŸ‘ Adding tables from the connection (SQLite is shown)

Gather the OData Url

Having configured a connection to DB2 data, created a user, and added resources to the API Server, you now have an easily accessible REST API based on the OData protocol for those resources. From the API page in API Server, you can view and copy the API Endpoints for the API:

πŸ‘ API Endpoints

Connect to DB2 Data as an External Data Source

Follow the steps below to connect to the feed produced by the API Server.

  1. Log into Salesforce and click Setup -> Develop -> External Data Sources.
  2. Click New External Data Source.
  3. Enter values for the following properties:
    • External Data Source: Enter a label to be used in list views and reports.
    • Name: Enter a unique identifier.
    • Type: Select the option "Salesforce Connect: OData 4.0".
    • URL: Enter the URL to the OData endpoint of the API Server. The format of the OData URL is https://your-server:your-port/api.rsc.

      Note that plain-text is suitable for only testing; for production, use TLS.

  4. Select the Writable External Objects option.
  5. Select JSON in the Format menu.

  6. In the Authentication section, set the following properties:
    • Identity Type: If all members of your organization will use the same credentials to access the API Server, select "Named Principal". If the members of your organization will connect with their own credentials, select "Per User".
    • Authentication Protocol: Select Password Authentication to use basic authentication.
    • Certificate: Enter or browse to the certificate to be used to encrypt and authenticate communications from Salesforce to your server.
    • Username: Enter the username for a user known to the API Server.
    • Password: Enter the user's authtoken.
πŸ‘ Configuration settings for the data source. (NetSuite is shown.)

Synchronize DB2 Objects

After you have created the external data source, follow the steps below to create DB2 external objects that reflect any changes in the data source. You will synchronize the definitions for the DB2 external objects with the definitions for DB2 tables.

  1. Click the link for the external data source you created.
  2. Click Validate and Sync.
  3. Select the DB2 tables you want to work with as external objects.
πŸ‘ Image

Access DB2 Data as Salesforce Objects

After adding DB2 data as an external data source and syncing DB2 tables with DB2 external objects, you can use the external objects just as you would standard Salesforce objects.

Troubleshooting

You can use the following checklist to avoid typical connection problems:

  • Ensure that your server has a publicly accessible IP address. Related to this check, but one layer up, at the operating system layer, you will also need to ensure that your firewall has an opening for the port the API Server is running on. At the application layer, ensure that you have added trusted IP addresses on the Settings -> Security tab of the administration console.
  • Ensure that you are using a connection secured by an SSL certificate from a commercial, trusted CA. Salesforce does not currently accept self-signed certificates or internal CAs.
  • Ensure that the server you are hosting the API Server on is using TLS 1.1 or above. If you are using the .NET API Server, you can accomplish this by using the .NET API Server's embedded server.

    If you are using IIS, TLS 1.1 and 1.2 are supported but not enabled by default. To enable these protocols, refer to the how-to on MSDN and the Microsoft technical reference.

    If you are using the Java edition, note that TLS 1.2 is enabled by default in Java 8 but not in Java 6 or 7. If you are using these earlier versions, you can refer to this this Oracle how-to.