Friday, June 28, 2013

Invoke Salesforce (SFDC) services from Oracle SOA BPEL

If you face below exception while invoking sales force services in BPEL, one of the probable reasons could be because of unavailability of the required sales force/SFDC certificates in Oracle SOA server.

Error:
<summary>
oracle.fabric.common.FabricInvocationException: Unable to access the following endpoint(s): https://login.salesforce.com/services/Soap/c/28.0
</summary>
<detail>
Unable to access the following endpoint(s): https://login.salesforce.com/services/Soap/c/28.0
</detail>
To resolve this, follow the below steps.

1) Download certificates by visiting the URL https://login.salesforce.com through any browser

Note:
In firefox, you can see a lock symbol in front of the URL. Click on it, a dialog will open, download the certificates from here.

2) Copy this certificate file(login.salesforce.com) to the machine where your soa server is running. I would suggest to copy the certificate file to JAVA_HOME/jre/lib/security.

3) Import certificates to Java trusted CA certs file (cacerts).

Note:
cacerts file will be available in your JAVA_HOME/jre/lib/security.
If you have many JDK versions installed and not sure about which one is your SOA server using, then you can find it in setDomainEnv.sh/setDomainEnv.cmd file.

4) Run the below command to import the certificate to cacerts file

          Change the directory to JAVA_HOME/jre/lib/security
          Command to import certificates

$keytool -import -alias login.salesforce.com -keystore cacerts -trustcacerts -file login.salesforce.com

If you face below error while running the keytool command 
  
$ keytool error: gnu.javax.crypto.keyring.MalformedKeyringException: incorrect magic

The error is because you may have more than one version of keytool running in your machine, with the help of locate command in unix/linux, identify the directories where keytool is installed.

$ locate keytool

Then modify the command with the absolute path to “keytool” as shown below,

$/u01/app/jdk16u/jdk1.6.0_20_org/bin/keytool -import -alias login.salesforce.com -keystore cacerts -trustcacerts -file login.salesforce.com

5) Modify the setDomainEnv.sh/setDomainEnv.cmd file to remove the DemoTrust.jks entry in Java Options. This will ensure that certificate that we imported into cacerts will be used as keystore.

6) Restart both admin and soa managed server

7) Make sure that the machine where soa server is available is able to reach login.salesforce.com. Use the ping command to know whether it is reachable. If you are not able to reach then, add an entry to the hosts file in /etc directory (in linux/unix)
8) Test the BPEL service which invokes SFDC service.

I hope this explains you in detail on how to import salesforce or SFDC certificates which helps the Oracle SOA services to successfully invoke SFDC services without facing security exceptions.

Friday, June 14, 2013

SOA 11g MDS - Sharing artifacts in MDS repository

SOA 11g MDS - Sharing artifacts in MDS repository


All SOA projects that are deployed on to SOA infrastructure are stored in the MDS repository. However the artifacts within the projects are not shared b/w each other. If you create a connection from the JDeveloper 'Resource Palette' to the SOA MDS, there will be a 'deployed composites' folder which will contain all deployed artifacts.

Sharing artifacts(like xsd's, wsdl's, xsl's) can be achieved as explained below.

 
SOA 11g provides us with MDS repository (file based & DB based). Common artifacts can be stored here and also can be referenced by all projects in the SOA infrastructure.

File based MDS is used during development time where as DB based MDS is used at run-time by the SOA infra.

During design time/development time store the common artifacts in file based MDS location(this is under the <Jdeveloper home>), then for it be available during runtime(for SOA-INFRA) and also if others in your team wants to reference it in their projects(in development state), it should be made available in DB Based MDS.

There are two steps to make artifacts to be shared.
1) Create File based MDS and place the artifacts
2) Upload it to DB based MDS.

Creating File based MDS and place the artifacts

First step here is to create the folder structure in the file based MDS as required.
Location: <jdeveloper-home>\integration\seed

General practice is to create 'apps' directory inside 'seed' and then create different folders based on artifact type it holds/stores.


To start referencing the artifacts that you placed in the above directories within your own projects in Jdeveloper, you have make sure to edit adf-config.xml file. This is available in every project that you create in Jdeveloper.

A configuration file named adf-config.xml is part of every SOA project manages this partition mapping to be used by JDeveloper during design/deploy time. 

Open the file and add the name space as shown in the screen below,

<namespace metadata-store-usage="mstore-usage_1" path="/apps"/>

 

After this we can start referencing the artifacts placed in the MDS as below

Open variables section in your BPEL process, and click on create variable and then click on import schema file on top right corner.

Use the location as mentioned in the URL section and click ok

 

Select the element and click OK


 
After the above steps, the below import statement will be placed in the process wsdl file.

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://xmlns.oracle.com/TestApplication/TestProject/PurchaseOrder"
schemaLocation="oramds:/apps/xsd/PurchaseOrder.xsd"/>
</xsd:schema>

At this point we have successfully created a File based MDS, placed the artifacts in it and also used it in our project.

However this is not enough for runtime processing, the next step is to make it available to SOA infra. That is, deploy it to DB-Based MDS. Once it is deployed to DB-Based MDS, the artifacts are visible to SOA-Infra and other developers who can access it and use in their projects.

To do this, you can use either Ant scripts or Jdeveloper, screens below shows how to deploy using Jdeveloper.

Step 1: Create a new application(Generic Application) and name the application as PurchaseOrderMDSApp and click next

Step 2: Provide name for the project (PurchaseOrderMDSProject)and click finish

Step 3: Right click on the project and select 'Project Properties'.
In the 'Project Properties' dialog, select 'Deployment' and create a new deployment profile by clicking on 'New' button

In the 'Create Deployment Profile' dialog, select 'Archive Type' as 'JAR File' and name the deployment profile as DBBasedMDSArchive and click 'OK'


 'Edit JAR Deployment Profile Properties' dialog opens up. Click on the 'Contributors' section under 'File Groups -> Project Output'.

Click on the 'Add..' button and select the folder where the 'artifacts to be deployed' is present.
File based MDS location can be selected where the content is already placed & available. Click OK


Click on the 'Filters' section and select the artifacts under the '/apps' that you would like to deploy or upload to MDS database repository. Click OK.

Click OK. JAR deployment profile is created, which contains the artifacts to be deployed on to SOA-MDS.

After this create the application deployment profile of type 'soa-bundle' which will be deployed to SOA-Infra. From the 'Application Menu', select 'Deploy' -> 'New Deployment Profile..' option 

Select SOA bundle and click OK

In 'Create Deployment Profile', provide name to the application deployment profile (soabundle1) and click OK

In the 'SOA Bundle Deployment Profile Properties' go to 'Dependencies' and select the JAR archive that we created earlier eg., DBBasedMDSArchive and click OK


 

Click OK

Deploy the application to the soa server. This will deploy all the selected artifacts under the '/apps' metadata namespace on to the SOA MDS database repository.

Verify the artifacts are deployed to DB Based MDS under apps using the MDS connection in Jdeveloper.

This completes MDS configuration for both File based and DB based repositories. To upload artifacts to MDS and to use it in the projects.