Thursday, March 27, 2014

Getting the Audit Detail of a BPEL instance in JAVA - Oracle SOA Suite

Getting the Audit Detail of a BPEL instance in JAVA - Oracle SOA Suite

In Oracle SOA Suite 11g and Oracle SOA Suite 12c,the audit trail of the BPEL is stored in the table AUDIT_TRAIL.If the size of the payload crossed the threshold size configured in the EM console then the details are stored in the AUDIT_DETAILS table.


The payload in the AUDIT_DETAILS table is in compressed binary form, you can use the below approach to get the actual payload.

import java.sql.*;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
public class GetPayload {
    public static Connection getConnection() throws Exception {
        Context ctx = null;
        Hashtable ht = new Hashtable();
        ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
        ht.put(Context.PROVIDER_URL, "t3://:8000");
        ctx = new InitialContext(ht);
        javax.sql.DataSource ds =(javax.sql.DataSource)ctx.lookup("jdbc/SOADataSource");
        return ds.getConnection();
    }

    public static String getPayload() {

        Statement stmt = null;
        Connection connection = null;
        ResultSet rs = null;
        
        String query="select  UTL_COMPRESS.LZ_UNCOMPRESS(b.bin) DOC from audit_details b where cikey='5148077' and rownum<2";
       
        String payload = "";
        try {
            connection = getConnection();
            stmt = connection.createStatement();
            rs = stmt.executeQuery(query);
            while (rs.next()) {                    
                Blob blob=rs.getBlob("DOC");
                byte[] sdata = blob.getBytes(1, (int) blob.length());;
                payload = new String(sdata);             
                
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (rs != null)
                    rs.close();
                if (stmt != null)
                    stmt.close();
                if (connection != null)
                    connection.close();
            } catch (Exception e) {

            }
        }
        return payload;

    }
}




No comments:

Post a Comment