Monday, June 15, 2015

Call Salesforce web service using cloud adapter


In order to create an account in Salesforce follow the following steps
Open https://login.salesforce.com/
And create a new account.
Once account is created ,Rest the Security token for your Salesforce account.
This step is required as the security token is used along with password to connect to Salesforce from weblogic server.
To reset your security token follow below steps:
At the top of any Salesforce page, click the down arrow next to your name. From the menu under your name, select Setup or My Settings—whichever one appears.



From the left pane, select one of the following:
If you clicked Setup, select My Personal Information | Reset My Security Token.
If you clicked My Settings, select Personal | Reset My Security Token.



Click the Reset Security Token button. The new security token is sent via email to the email address on your Salesforce user record.

Next is to download the certificates for the cloud service

In order to Generate certificates of Salesforce to be used in Weblogic Server do the following steps
Login to Salesforce.com
There you will get a lock icon. Click on that and it will give you certificate information.





Click on Certificate information and go to Details tab as shown below




Select Copy To File. This will open up a new wizard to export the certificates




Select Base 64 encoding



Save it to your local machine. The name provided here for Certificate is SalesForceCA



Make sure to download intermediate certificate if there are any. One such intermediate certificate is shown below.



Make sure that all the chain of certificates are downloaded.

Once all the certificates are downloaded, the next step is to import them in weblogic server

Once you have the certificates with you can import these certificates in to the keystore of weblogic server.
Login to your weblogic server.
http://host:port/console
Navigate to your ServerAdmin ServerKeystore and check out the location for the DemoTrust Keystore as highlighted below




Once you are aware of the path for key store. Navigate to the location in command prompt and use the following command to import the certificate in the key store.
keytool -import -trustcacerts -alias SalesForceCA –file -keystore DemoTrust.jks -storepass DemoTrustKeyStorePassPhrase
Here SalesForceCA is the name of the certificate that you have downloaded.



When asked to import the certificate Say yes. Validate if the certificates are getting imported correctly



You can use the following command to validate if the certificates are imported successfully or not.
keytool –list –keystore DemoTrust.jks -storepass DemoTrustKeyStorePassPhrase





Create authentication key

Once the certificates are imported to the Keystore of weblogic , lets create a authentication key that will be used during design time to connect to the salesforce.
Login to the em console
http://host:port/em
Then Navigate to the following path
Weblogic DomainYour Domain
Right Click on your domain.
Go to Security and select Credentials as shown below.





Once you are in Credential page.
Create a new Map




Name the Map as SOA




Select the newly created MAP and click on Create Key.




Give Key name as SalesForceKey.
Select Type as Password
UserName – User name for your Salesforce account.
Password – The password has to be formed in following way.
If your password for Salesforce account is abc and the security token is xyz
Then the Password that you will pass in authentication key is abcxyz
i.e. your Salesforce password+Security token will be the Password in Authentication key.



Say ok an now you can go back to the Credential store and validate if the key is created or not.



Once authorization key is created, we need to have the enterprise wsdl to create a session and call business services in the Salesforce

In order to connect to Salesforce at design time from Jdeveloper we need to download the Enterprise WSDL from the Salesforce.
To download the Enterprise WSDL
Login to Salesforce.com
Go to Set up
In the left hand side
Under Build Expand the Develop tab
Go to API and click on Generate Enterprise WSDL as shown in diagram



It will open up the WSDL file in a browser as shown below



Save the WSDL file to your local Machine. This will be used later while making a connection to Salesforce at design time in Jdeveloper.

Once enterprise wsdl is downloaded the next step is to register the ip address in Salesforce

When a user tries to access Salesforce.com via a new IP address or machine, Salesforce.com requires a verification code to be entered for the user. This code is mailed to the user’s registered e-mail address. To overcome this issue, a list of IP address ranges can be set for all users from which they can always log in without facing such issues.
In order to register your ip address do the following steps
Login to Salesforce.com
Go to Set up
Security ControlsNetwork Access
Specify your ip address range as shown below.




Now all the configuration is done , only job is to create a bpel process to call any Salesforce service using Cloud adapter provided by Oracle Jdev 12c

You can also get more information the same from oracle tutorial

https://blogs.oracle.com/SOA/entry/integrating_with_salesforce_com_video

29 comments:

moneymonk said...

Hi
When I try to do the same I am getting an error:

unable to connect to salesforce server

Please let me know what could go wrong?

Mikku said...

If you could let me know what all steps you followed and in which stage you are getting this error, i will be able to help you.

Make sure you have imported the chain of certificates from Salesforce and are properly imported in key store of weblogic server.

Once imported you can validate in key store if the certificates are imported properly or not.

Other than that all steps are straight forward and you should be able to connect

moneymonk said...

1. I tried the same steps with Jdev 12c and it worked.
I am able to create salesforce adapter and deploy the process to SOACS. But I am not able to invoke the service. I am getting following error.

An exception occurred while invoking the webservice operation. Please see logs for more details.
oracle.sysman.emInternalSDK.webservices.util.SoapTestException: Client received SOAP Fault from server : Exception occurred when binding was invoked.
Exception occurred during invocation of JCA binding: "JCA Binding execute of Reference operation 'create' failed due to: Unable to create Cloud Operation: ".
The invoked JCA adapter raised a resource exception.
Please examine the above error message carefully to determine a resolution.


2. I tried the above steps with 11g and local weblogic setup, but I am unable to connect to salesforce server. Java version used is: 1.7

moneymonk said...

And this error while invoking request to the composite:
JPS-06530: Invalid stripe value null

Mikku said...

ok you need to make sure you are at right patch level if you are trying to use the backported SFDC adapter in 11g, the exact patch information you can get from metalink.

From the 12c perspective i will suggest you to check following details

1) Check csf-key
2) User access in SFDC
3) HostName verifier unchecked in weblogic
4) Certs for Salesforce environemnt
5) Certs for intermediate Server URL if different from previous one
6) The IP address of the server making connection should be added as Trusted IP in Salesfoce
7) Check the API version of Salesforce. v29 would be best . But it works with v30 and v31 as well.
8) Test from Jdev , by using the query option if you are able to connect---> This is a good test from design time and will validate if you are able to connect to salesforce and query the data.


Further are you also getting issues like

unable to find valid certification path to requested target or any other certificate issues?

moneymonk said...

Thanks a lot for the quick response.

1) Check csf-key Done as the connection is successful while creating Salesforce Adapter
2) User access in SFDC I can invoke from SOAP U/I
3) HostName verifier unchecked in weblogic
4) Certs for Salesforce environment Copied two certificates from salesforce and imported both to the keystore
5) Certs for intermediate Server URL if different from previous one Same as above point??
6) The IP address of the server making connection should be added as Trusted IP in Salesforce In network access I have unblocked the my ip from which the request is going
7) Check the API version of Salesforce. v29 would be best . But it works with v30 and v31 as well. API version is 35.0 Any idea how to use previous versions?
9) I am unable to deploy directly from jdev to 12c cloud server.Unable to create connection. I am using sar file. Anyway to directly deploy to soacs?

moneymonk said...

The problem seems to be mainly with the certificate. Do I have to use only CA certificate provided by salesforce? I tried with self-signed certificate which didn't work.
I tried to create CA certificate but I got this message:
You cant use this certificate until its signed by a certificate authority and imported to your organization

moneymonk said...

Sry if am asking too much.
Can you let us know if the integration works fine for current version of salesforce api

Mikku said...

I got your issue i have faced this issue as well.

The problem is with certificate import only.

You have to import the certificates from salesforce and you have to make sure you are importing the chain of certificates. I believe you are just importing the final certificate as i had faced the issue.

Please ensure you are importing chain of certificates at all level and then try to import it in weblogic server keystore.

The last version i tried was with v29 , but it should work with higher version as well.

moneymonk said...

I have imported two certificates. The third certificate *.salesforce is not enabled to view certificate.

Mikku said...

I believe when you say you have migrated two certificates i assume you exported two certificates

Verisign and Symantec Class 3 Secure Server CA - G4

It should be

Symantec Class 3 Secure Server CA - G4

and

saleforce.com

you need to export these two certificates and import in key store.

When you go to certification path while downloadin certificate, just click on each of these item and then go to details tab, From there you can copy it to file.

If it is a certificate issue, it is for sure that you are either not importing certificates properly or you have missed one of the certificate.

When you import make sure you are giving two different name to the certificates and then importing both of them.

Once you import both the certificates , you can run the following command in key store to validate both the certificates are correctly imported or not.


keytool –list –keystore DemoTrust.jks -storepass DemoTrustKeyStorePassPhrase

moneymonk said...

Hi Mikku,

Thanks a lot for your replies. I am now able to invoke Salesforce service from Weblogic in my local system. Now trying the same with SOA Cloud.

Mikku said...

Great, Do post your solution steps as well so that it will be helpful for others as well who are facing the same issue.

moneymonk said...

One important thing to note.. Always try to use the Keytool command rather than importing via weblogic. Secondly import the self-signed certificate from salesforce as well, which can be obtained by searching for 'Certificate and Keys' in salesforce API.

Unknown said...

Hi. I explain all the steps and when I'm in the adapter configuration window (Step 2 of 5) and run the test appears Sucess me, but when I give in netx me an error window appears with java.io.UTFDataFormantException: Invalid UTF-8 encoding.

Any idea how to fix it? And why you get this?

Unknown said...

Hi. I explain all the steps and when I'm in the adapter configuration window (Step 2 of 5) and run the test appears Sucess me, but when I give in netx me an error window appears with java.io.UTFDataFormantException: Invalid UTF-8 encoding.

Any idea how to fix it? And why you get this?

Unknown said...

Hi. I explain all the steps and when I'm in the adapter configuration window (Step 2 of 5) and run the test appears Sucess me, but when I give in netx me an error window appears with java.io.UTFDataFormantException: Invalid UTF-8 encoding.

Any idea how to fix it? And why you get this?

Mikku said...

Have not faced this issue earlier

but it could be due to the version of salesforce

Check the API version of Salesforce. v29 would be best . But it works with v30 and v31 as well.

Prashanth said...

Hi,

I followed the same steps and from my BPEL calling the SFDc adpater.
When i am trying to deploy the composite i am getting below eero.
"Error deploying credential "SFDC_USER" in "SOA" map. Credential already exists on the server and does not match passed in credential"
I have created the same key in SOA map of my em.

Please guide me in this

Prashanth said...

Hi
I have followed the steps to configure Certificate and key.
I have a BPEL process with SFDC adapter and when i am trying to deploy gives me error
"Error deploying credential "SFDC_USER" in "SOA" map. Credential already exists on the server and does not match passed in credential".

Created the key SFDC_USER in SOA map.
Please guide me what could be the issue.

Mikku said...

AS per the error message i believe you are facing issue with security key.

Is your security key "SFDC_USER" make sure you do not have a space before and after the key.

Try to recreate the key and restart the server.

Khavi said...

Hi
How do we change the salesforce end point URL from the salesforce enterprise wsdl.

Thanks,
Khavi

Unknown said...

This blog explains the details of most popular technological details. This helps to learn about what are all the different method is there. And the working methods all of that are explained here. Informative blog.
salesforce training in chennai

Sreenivas Reddy said...

Hello Mikku,

Very useful information. Initially I also did same mistake that I just imported only one certificate(*.salesforce.com) instead of chain of certificates.

After following your conversations in comments my issue also got resolved.

suggestion : If you don't mind, instead of mentioning chain of certificates you can mention certificates names in main description. So that people can able to establish the connection successfully in first attemt itself.

Thanks,
Sreeni

Dipendra said...

while configuring salesforce cloud adapter, when i add an Authentication key an error occurs "The csfkey= SFDC already exists..." i tried with different alias names but the error is same. please guide me how to resolve it.

Dipendra said...

while

Jayanthi said...

Hi,
I am getting issue while trying to import the slesforce certificate through keytool command.Please help me in resolving it.
The issue is
Illegal option:?file

Thanks
Jayanthi Devadoss

Jayanthi said...

Hi,
I am getting some issue while trying to import certificate to weblogic server through Keytool command
the issue is
"illegal option:?file"

Thanks
Jayanthi Devadoss

Nathan Duference said...

Excellent read, Positive site, I have read a few of the articles on your website now, and I really like your style.
Thanks a million and please keep up the effective work and also get to know about Salesforce Sales Cloud Consultant