Matter faced during integration project

Sunday, September 12, 2010

Connecting to Ariba with a Java API

To connect to Ariba, you use the Ariba Integration Toolkit. It consists of java libraries and batch scripts.
Using the batch script was uneasy for us, as it means we had to schedule 2 jobs: one to get or retrieve the files from Ariba and another job to process the file.

A much easier solution, was to call the Ariba java library straight away from our java code. To do that we had to dig into the batch file and decompile the java code.
Then to call the Ariba Java API, you simply add Ariba libraries to your classapth and you call the following code:

public class CallAriba {

public static void main(String[] args) {

String[] s = buildArg();

ariba.filetransferclient.Main.main(s);

}

private static String[] buildArg() {

String[] arguments = {

"get",

"-url",

"https://s1.ariba.com/Buyer/filedownload?realm=myCompanyRealm",

"-sharedSecret",

"myCompanySharedSecret",

"-downloadDir",

"C:/temp/ariba",

"-timestampFile",

"C:/temp/ariba/time.txt",

"-filePrefix",

"OK2Pay",

"-logFile",

"C:/temp/ariba/logs/log-test.log",

"-proxyHost",

"10.0.225.201",

"-proxyPort",

"8080",

"-unzipDirs",

"false",

"--",

"-event",

"Export Payment Requests"};

return arguments;

}

Wednesday, March 3, 2010

Sending SOAP request with JDK library



private static synchronized
String sendSOAPRequest(String soapMsg, String webserviceMethod, String soap_Endpoint) throws Exception {
try {
URL url = new URL(soap_Endpoint);
// setup HTTP Connecten to the service
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.setDoInput(true);

// create SOAP Request
connection.setUseCaches(false);
connection.setRequestProperty("Content-type", "text/xml; charset=iso-8859-1");
connection.setRequestProperty("SOAPAction", webserviceMethod);
System.out.println("SOAP-Endpoint: " + url);
System.out.println("SOAP-Action: " + webserviceMethod);

// send SOAP-Request
byte[] bytes = soapMsg.getBytes();
connection.setRequestProperty("Content-length", String.valueOf(bytes.length));
OutputStream out = connection.getOutputStream();
out.write(bytes);
out.close();

// read SOAP-response
BufferedReader in;
try {
in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
} catch (IOException e) {
if (connection.getResponseCode() == 500)
in = new BufferedReader(new InputStreamReader(connection.getErrorStream()));
else
throw e;
}
// handle the SOAP response
StringBuffer in_buffer = new StringBuffer(8192);
String temp = "";
while ((temp = in.readLine()) != null) {
in_buffer.append(temp);
}
in.close();
return in_buffer.toString();
} catch (Exception e) {
System.out.println("!!! Exception: " + e);
throw e;
}
// return "";
}

Tuesday, February 16, 2010

BPEL and Oracle Siebel CRM On Demand

When integrating OCOD (aka Oracle Siebel CRM On Demand) using BPEL and Java application,
issues arise for:
1. keeping credentials session open with Oracle CRM On Demand because OCOD accept only 10 concurrent session + it is faster to re-use existing session
2. OCOD refuse 2 request to be made without 50ms between each requests
3. session need to be reset if OCOD server restart

An option is to add the session id to the end point of the partner link in the BPEL process.
Another option is to use java embedded code in BPEL and login and loggof to OCOD.

Those 2 options did not really fit with our requirements. Too slow, not scalable, dodgy to maintain, etc...

Our approach has been to use a proxy between our BPEL engine and OCOD.
So all partner link to OCOD from our BPEL process use this proxy as the end point for the partner link. Thus all calls from our application to OCOD is going through this proxy.

It consist of a Java web application deployed as a war file (11Kb) it manages:
- sessions
- authentication (so no password in clear text inside our BPEL process)
- the 50 ms wait that must exist between each request to OCOD

The code for this proxy is located here:

you can check it out like that:

# Non-members may check out a read-only working copy anonymously over HTTP.
svn checkout http://ocod-proxy.googlecode.com/svn/trunk/ ocod-proxy-read-only
The idea is to make it public so that anybody can use it and tell if he meets any issues.
Then tell me if you want to modify and enhance it. I would provide an access to the SVN repository.