Sunday, December 31, 2017

How to integrate with Salesforce.com through Salesforce Adapter in Oracle SOA Suite 12c

How to integrate with Salesforce.com through Salesforce Adapter in Oracle SOA Suite 12c

Oracle SOA Suite Salesforce adapter helps to integrate with Salesfore to perform different operation on objects like CURD, QUERY etc.
This post will explain the approach to configure Salesfore Adapter to perform different operations.

Installing Salesforce.com  SSL certificates to Weblogic server:


Download the certificates(I am using the test salesforce instance): 


Open login.salesforce.com in browser(here I am using chrome browser)
Click on certificate icon and valid

export_salesfoce_login_certificate


Click on Details and Copy to File

export_salesfoce_login_certificate


Click on Next


Select the format as Base-64 encoded X.509(.cer) and click on Next

export_salesfoce_login_certificate


Specify the file location to export and click on Next

export_salesfoce_login_certificate


Click on Finish

export_salesfoce_login_certificate

Now the certificate is exported to login.salesforce.com.cer

Repeat the same steps to retrieve the certificate for Salesforce API URL(API URL will be different based on the instance but the wildcard certificate(*.salesforce.com) is used so installing once will support different URL's)

Copy the certificate to salesforce.com.cer

export_salesfoce_login_certificate

Install the certificates:


Install both the SSL certificates to weblogic server DemoTrust.jks store.

keytool -import -alias salesforce.com -keystore C:\Albin\SW\SOA-12c\Oracle\Middleware\Oracle_Home\wlserver\server\lib\DemoTrust.jks -file C:\Albin\workarea\salesforce.com.cer

Password: DemoTrustKeyStorePassPhrase

Trust this certificate : yes

install_certificate_weblogic_demo_keystore

Certificate was added to keystore

keytool -import -alias login.salesforce.com -keystore C:\Albin\SW\SOA-12c\Oracle\Middleware\Oracle_Home\wlserver\server\lib\DemoTrust.jks -file C:\Albin\workarea\login.salesforce.com.cer

Password: DemoTrustKeyStorePassPhrase

install_certificate_weblogic_demo_keystore


Certificate was added to keystore

List the certificates to make sure the installation was successful.

keytool -list -keystore  C:\Albin\SW\SOA-12c\Oracle\Middleware\Oracle_Home\wlserver\server\lib\DemoTrust.jks

Password : DemoTrustKeyStorePassPhrase

install_certificate_weblogic_demo_keystore


Restart the weblogic server

Generate enterprise WSDL:


Login to Salesforce.com
Click on Setup

generate_saleasforce_enterprise_wsdl

Search for API and Click on API

generate_saleasforce_enterprise_wsdl

Click on Generate Enterprise WSDL

generate_saleasforce_enterprise_wsdl

Save the file as "enterprise.wsdl" to the local system

generate_saleasforce_enterprise_wsdl

Configure CSF Key:


The CSF key will be used by SOA server - Salesforce Adapter during run-time to fetch the UserName/Password to connect to the Salesforce URL's

Login to em console
Click on Target Navigation - Weblogic Domain - Right Click on Domain name - Security  - Click on Credential

configure_credential_map_soa_server


Create Map - oracle.wsm.security(ignore this if the map already exists)

configure_credential_map_soa_server

Click OK

Create Key(enter unique name) under oracle.wsm.security(the map created in the above step)

Eneter username and Password

Note that password is the combination of  passwordand SecurityToken(password+SecurityToken -  e.g. Test123!g4NPc4iae6wzgOD66Yxxxxxx)

configure_credential_map_soa_server


Click on OK

Note the key value(salesforce-credential) for design time configuration

To retrieve the Security Token - Login to Salesforce.com, Click on Setup - My Personal Information - Reset My Security Token - Click on Reset Security Token

The new security token will be send to the configured email id.

reterive_salesforce_securitytoken


Design the composite with Salesforce Adapter:


Create a Composite with BPEL component

Drag and drop the Salesforce Cloud adapter to External Reference and change the endpoint nae as required

configure_salesforce_adpater

Click on Next

Enterprise WSDL Location - Select the enterprise.wsdl exported in the earlier steps.

configure_salesforce_adpater

Authentication Key - Click on plus to define new Authentication Key

Enter the CSF key name defined in earlier step
UserName
Password - Password is the combination of Password+Security Token

configure_salesforce_adpater
Click on OK

Click on Test to verify the connection - "Connection was established successfully" message will be displayed on successful connection

configure_salesforce_adpater

Click on Next

Select the Operation Type and the Object -e.g. CRUD - Create and Account Object

configure_salesforce_adpater

Click on Next
Select if any Header Operation required and Click on Next
Click on Finish

Connect the BPEL component with Saleforce connector reference

configure_salesforce_adpater

Open BEPL process and add the Invoke activity to invoke the Salesforce adapter to create the Account - Create the input/output variables for the activity

Add a assign activity to assign the input data to invoke activity - assign the value to required fields, make sure the value for the mandatory fields to create the account are assigned

configure_salesforce_adpater

configure_salesforce_adpater_bpel


Deploy the composite and test

account_creation_through_salesforce_adapter

The response will contains the account id on successful creation.

account_creation_through_salesforce_adapter


account_creation_through_salesforce_adapter

Update to Account Object:


Create the Adapter configuration with CRUD - Update operation

salesfore_adapter_update


Assign the values to update - Assign the account id and the other values to be updated.

salesfore_adapter_update

Now the account with the specified account is updated with provided data.

salesfore_adapter_update

salesfore_adapter_update


SOQL to retrieve the account details:


Create the Adapter configuration with SOQL- query

salesfore_adapter_SOQL_query

The query can be tested in design time - Click on Test My Query that display the result.

To specify the parameter to the query add the bind variable for the required parameters - Account number is assigned as a parameter with bind variable, the query can be tested design time by providing the value for the bind variable 

salesfore_adapter_SOQL_query

Assign the input parameters - the parameters should be specified with in quotes(e.g. - '1234', in BPEL assign specify the value as "'1234'")

salesfore_adapter_SOQL_query

On Execution the details corresponds to the account id will be retrieved.

salesfore_adapter_SOQL_query

Apart from CURD and SOQL operations, the Adapter supports SOSL, Core and Misc types.


1 comment:

  1. Hi,
    I am able to establish the connection but getting "Connection refused" issue in the next operation i.e.operation.Kindly help me to resolve it.

    ReplyDelete