Friday, July 25, 2014

Thursday, July 24, 2014

Cipher not initialized exception while invoking the Salesforce service through OSB

We are getting the "Cipher not initialized" exception wile invoking the Salesforce services through OSB.

We are able to invoke the URL successfully and able to receive the session id, also this exception was thrown only for a particular sandbox but the all other sandbox invocation is successful.

The "Cipher not initialized" exception will be thrown when there is no common Ciphers available between the client and server while negotiating the SSL communication.

We have raised a case with Salesforce regarding this and receive the response as "We recently upgraded our Cipher suites for SSL. To resolve the issue upgrade latest version of Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files- 6 for JDK1.6 on middleware."

After upgrading the Unlimited Strength Jurisdiction Policy Files in all the servers nodes we are able to invoke the service successfully.

Follow the below steps to resolve the issue

  • Download the Unlimited Strength Jurisdiction Policy Files from Additional Resources" section), for java 1.6 use
  • Unzip the downloaded zip 
  • Copy local_policy.jar and US_export_policy.jar to the $JAVA_HOME/jre/lib/security in all the OSB nodes.
  • Restarts the servers.
Now you will be able to invoke the service successfully.

Tuesday, July 15, 2014

Don't support MessageVariable in fromPart - Oracle SOA 11g

This error will be thrown while invoking the service with Multipart Message type and the receive activity uses the fromPart to retrieve the parts data and assign to a variables created based on message type or invoke activity uses toPart to assign the data to parts based message type variable.

To resolve this whenever retrieving or assigning values to parts in receive/invoke activity through fromPart or toPart use the element based variables instead using the message type based variable.

Multipart Message Support in Oracle BPEL

Thursday, July 10, 2014

Integrating CQ5 with REST services

The below document explains the approach to integrate CQ5 with REST services.

Download Integrating_CQ5_with_RESTServices.pdf

Saturday, July 5, 2014 Server returned HTTP response code: 400 - While invoking the Salesforce login url from java to get the access token

I was getting the below exception while invoking the Salesforce login url to get the OAuth access_token from java. Server returned HTTP response code: 400 for URL:
at RestCaller.execute(
at RestCaller.main(

This exception will happen normally when the values of client_id, client_security, username and password are not specified correctly while invoking the login url - to get the OAuth access token.


In my case, I have specified all the values properly but still it was not working, it worked after resetting the password and getting the new security token - password(password+security token)

Calling Salesforce REST based webservice from Java

This post will explain the approach to call the Salesfore REST based webservice through java.
I have exposed a Apex class as REST service from salesforce to fetch the account details.

global with sharing class AccountDetails {

    global static Account doGet() {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        String accountId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        System.debug('Account Id:'+accountId);
        Account result = [SELECT Id, Name, Phone, Website FROM Account WHERE Id = :accountId];
        return result;

The communication is of two steps

  •  getting the access_token 
  •  invoking the service endpoint by attaching the access_token to the request.

To obtain an access token, we will send an HTTP POST request to the authentication endpoint exposed by Salesforce -  with the details client_id, client_secret, username and password.This values can be get from the configured Connected Apps from salesforce.

import org.w3c.dom.*;

public class RestCaller {
public static void main(String[] args) throws Exception {

String urlParameters = "grant_type=password&client_id=3MVG9Y6d_xxxxxxxx&client_secret=80xxxxxxxx&username=albinsharpxxxxx&password=xxxxxxxxx";

String loginresponse = RestCaller.execute(
"", "POST",urlParameters, "application/x-www-form-urlencoded", null);
String sessionId=getSessionId(loginresponse);
String serviceResponse =RestCaller.execute("","GET","0019000000AZBCNAA5","application/xml",sessionId);
System.out.println("Service Response \n" + serviceResponse);

public static String execute(String targetURL, String HttpMethod,
String urlParameters, String contentType, String SessionId) {
URL url;
HttpURLConnection connection = null;
try {
url = new URL(targetURL);
if (HttpMethod == "GET") {
url = new URL(url.toString() + "/" + urlParameters);
connection = (HttpURLConnection) url.openConnection();
if (SessionId != null)
connection.setRequestProperty("Authorization", "OAuth "+ SessionId);
connection.setRequestProperty("accept", "application/xml");
if (HttpMethod == "POST") {
connection.setRequestProperty("Content-Length","" + Integer.toString(urlParameters.getBytes().length));
connection.setRequestProperty("Content-Type", contentType);
connection.setRequestProperty("Content-Language", "en-US");
OutputStream os = connection.getOutputStream();
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));

InputStream is = connection.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
String line;
StringBuffer response = new StringBuffer();
while ((line = rd.readLine()) != null) {
return response.toString();
} catch (Exception e) {
return (e.getClass().getName());

finally {
if (connection != null) {


static String getSessionId(String loingResponse)
{ sbis = new;
       javax.xml.parsers.DocumentBuilderFactory b = javax.xml.parsers.DocumentBuilderFactory.newInstance();
       org.w3c.dom.Document doc = null;
       javax.xml.parsers.DocumentBuilder db = null;
       try {
           db = b.newDocumentBuilder();
           doc = db.parse(sbis);
       } catch (Exception e) {
       org.w3c.dom.Element element = doc.getDocumentElement();
       String access_token="";
       NodeList nodeList = element.getElementsByTagName("access_token");
       if(nodeList!=null && nodeList.getLength() > 0){
        Element myElement = (Element)nodeList.item(0);
        access_token= myElement.getFirstChild().getNodeValue();
       return access_token;

<?xml version="1.0" encoding="UTF-8"?>
<response xsi:type="sObject" xmlns:xsi="">
<Phone>(650) 867-3450</Phone>