Friday, March 12, 2010

Android/Oracle BPEL

I was able to build a Android app which calls a Oracle BPEL Webservice and process the response sent back from the Service.

This is what i did.

created a Simple BPEL Process and Deployed to BPM 10.1.3.4

Created an Android App on the Eclipse(Android SDK) named it as BPELAndroid.

Added the ksoap2 jar file downloaded from

http://code.google.com/p/ksoap2-android

Note:
When i Called the service from a Blackberry i used a ksoap jar file ksoap2-j2me-core-prev-2.1.2.jar. This JAR file has a HTTPTransport class

This HTTPTransport class will not work for Android.


Wrote the Code below.

package com.prem.android;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import android.app.Activity;
import android.os.Bundle;

public class BPELAndroid extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SoapObject userLoginReposne = null;

try{
HttpTransportSE ht = new HttpTransportSE(
"wsdl url");

/*Please make sure you have VER11 to invoke the BPEL Webservice

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);

SoapObject request = new SoapObject(
"http://xmlns.mascocs.com/TheLoop/request",
"name of soap object");

request.addProperty("employeeName","1021633");

request.addProperty("pword","Masco123");

request.addProperty("token","");

envelope.setOutputSoapObject(request);


ht.call("opertatioName",envelope);

userLoginReposne = (SoapObject) envelope.bodyIn;

System.out.println("the request 1 is"
+ userLoginReposne.toString());

setContentView(R.layout.main);

}catch(Exception e){
System.out.println("the Exception is"+e.toString());
}

}
}

No comments: