Saturday 16 September 2017

OIM API - Stand Alone Code to Read Process Form Data.

  To execute below code you have to add following jars in classpath:

  • commons-logging.jar
  • eclipselink.jar
  • jrf-api.jar
  • oimclient.jar
  • spring.jar
  • wlfullclient.jar

 

Stand Alone Code:


public class ProcessFormDataOps{
       static OIMClient oimClient = null;
        
        //identity self service details
        String username = "xelsysadm";
        String password = "<password>"; //xelsysadm password
        String t3url = "t3://<hostname>:<port>"; //OIM HostName and Port
        String authwl_location = "<location of authwl.conf file in your local machine>"; //eg. D:\\authwl.conf
        
        public void getOIMConnection() {
            System.out.println("getOIMConnection() : Start");
            //set system properties
            System.setProperty("java.security.auth.login.config", authwl_location);
            System.setProperty("OIM.AppServerType", "wls");
            System.setProperty("APPSERVER_TYPE", "wls");
    
            Hashtable oimenv = new Hashtable();
            oimenv.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, "weblogic.jndi.WLInitialContextFactory");
            oimenv.put(OIMClient.JAVA_NAMING_PROVIDER_URL,t3url); 
            oimClient = new OIMClient(oimenv);
            try {
                oimClient.login(username, password.toCharArray());
                System.out.println("Connected");
            } catch (LoginException e) {
                e.printStackTrace();
            }
            System.out.println("getOIMConnection() : End");
        }

public void getProcessFormData(long processInstanceKey){
   System.out.println("getProcessFormData() : Start");
tcFormInstanceOperationsIntf formInstanceIntf = oimClient.getService(tcFormInstanceOperationsIntf.class);
try {
tcResultSet trs = formInstanceIntf.getProcessFormData(processInstanceKey);
int count = trs.getRowCount();
for (int i = 0; i < count; i++) {
trs.goToRow(i);
String columnNames[] = trs.getColumnNames();
for (String fieldName : columnNames) {
System.out.println(fieldName + " :: " + trs.getStringValue(fieldName));
}
}
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("getProcessFormData() : End");
}
public static void main(String[] args) {
ProcessFormDataOps processFormDataOps = new ProcessFormDataOps();
processFormDataOps.connect();
long proInsKey = 140683; //Process Instance Key
processFormDataOps.getProcessFormData(proInsKey);
}
}


Happy Learning!!!

1 comment:

  1. Hi,

    I am getting below error:

    failed to unmarshal return type: interface Thor.API.tcResultSet; nested exception is:
    java.io.InvalidClassException: com.thortech.xl.dataaccess.tcDataSet; local class incompatible: stream classdesc serialVersionUID = -5175239177076077032, local class serialVersionUID = -6798981945485330052
    at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.unwrapRemoteException(RemoteBusinessIntfProxy.java:130)
    at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:97)
    at com.sun.proxy.$Proxy20.getProcessFormDataInViewModex(Unknown Source)
    at Thor.API.Operations.tcFormInstanceOperationsIntfDelegate.getProcessFormDataInViewMode(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at Thor.API.Base.SecurityInvocationHandler$1.run(SecurityInvocationHandler.java:68)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:323)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
    at weblogic.security.Security.runAs(Security.java:43)
    at Thor.API.Security.LoginHandler.weblogicLoginSession.runAs(weblogicLoginSession.java:52)
    at Thor.API.Base.SecurityInvocationHandler.invoke(SecurityInvocationHandler.java:79)
    at com.sun.proxy.$Proxy21.getProcessFormDataInViewMode(Unknown Source)
    at SearchRole.getProcessFormData(SearchRole.java:131)
    at SearchRole.main(SearchRole.java:227)

    ReplyDelete