Saturday, December 10, 2011

Base64 Encoding/Decoding in Oracle BPEL 11g


Base64 Encoding/Decoding in Oracle BPEL 11g:

Sometimes we may need to send the binary data to the reference services or decode the binary data received from the services in BPEL. The Java Embedding activity can be used to Encode/Decode the binary data.

Encoding the XML data:

The below Java Embedding Code snippet will retrieve the XML data and encode the same to the binary format and assign the encoded data to the BPEL variable.


oracle.xml.parser.v2.XMLElement inputPayload = (oracle.xml.parser.v2.XMLElement)getVariableData("inputVariable","payload","/client:process");
oracle.xml.parser.v2.XMLDocument xmlPayload = inputPayload.getDocument();
java.io.ByteArrayOutputStream outputStream = new java.io.ByteArrayOutputStream();
try {
xmlPayload.print(outputStream );
java.lang.String xml_output = outputStream.toString();
oracle.soa.common.util.Base64Encoder encoder = new oracle.soa.common.util.Base64Encoder();
java.lang.String encodedString = null;
encodedString = encoder.encode(xml_output);
setVariableData("base64EncodedString",encodedString);
outputStream.close();
} catch (Exception e) {
e.printStackTrace();
}

Decoding the Binary Data:

The below Java Embedding Code snippet will retrieve the binary data and decode the same to the XML format and assign the decoded data to the BPEL variable.


String input = (String)getVariableData("base64EncodedString");Base64Decoder Decoder = new Base64Decoder();
try
{
String decodedString = Base64Decoder.decode(input);
setVariableData("decodedString",decodedString );
}
catch(Exception e)
{
e.printStackTrace();
}

Before deploying the Composites, make sure the oracle.soa.common.util.Base64Decoder/ oracle.soa.common.util.Base64Encoder classes has been imported in the bpel file.



O/P


DOWNLOAD SAMPLE


Wednesday, December 7, 2011

Oracle SOA Suite 11g – Advanced Configurations for Database Adapter.

Oracle SOA Suite 11g – Advanced Configurations for Database Adapter.

This blog give the insight on the new features in Database Adapter configuration in Oracle SOA Suite 11g.

Query by Example:

A new Operation type 'Query by Example' has been introduced in Database Adapter Configuration. Query By Example does not require a selection criteria to be specified at design time like SELECT Operation. A selection criteria is inferred from an exemplary input XML record for each invoke. Use queryByExample when you do not want to create a query using the visual query builder and want the flexibility of allowing the input record to share the same XML schema as the output records. The queryByExample operation is will take little more time compared to SELECT operation because a new SELECT must be prepared for each execution.

Doing Synchronous Post to BPEL (Allow In-Order Delivery):

In this feature, the entire invocation is in a single thread and global transaction. By default, initiation is asynchronous and the BPEL process is invoked in a separate global transaction. With Oracle Mediator, it is generally a synchronous invoke so this is only specific to an Oracle BPEL process.


Advanced Options:

A new screen in Adapter configuration wizard for advanced options is added. This screen shows different options based on the type of operation selected. The below are the some of the advanced configurations.

Auto-Retries:

We can set options like no. of retry attempts, interval between retries back-off factor and max interval values.

JDBC Options: 

This includes options like Query timeout value to specify the timeout for query execution.

Interaction Options: 

This includes various interaction options. Get Active UnitOfWork ( advanced setting that forces all invoke activities in the same global transaction to use the same SQL connection if going to the same database), Detect Omissions (allows the MERGE and INSERT operations to ignore empty or missing XML elements in the input payload), Optimize Merge (should always be set to true, as it is a general enhancement to MERGE performance)



Tuesday, December 6, 2011

Oracle SOA Suite - Custom Data Publisher for Sensor Action.


Oracle SOA Suite - Custom Data Publisher for Sensor Action.

This blog will explain the steps to create the custom data publisher for the sensor action in Oracle SOA Suite 11g or Oracle SOA Suite 12c(the same steps will work in Oracle SOA Suite 12c but the screens will be different) .

Steps to create custom data publisher

1. Create the java class e.g. MyCustomSensorPublisher that implements the class DataPublisher in the composite project.
Implement the method - public void publish(ITSensorAction action,ITSensorActionData actiondata,Element xml) to publish the event to the custom publisher.


package customjavasensor;
import com.oracle.bpel.sensor.DataPublisher;
import com.oracle.bpel.sensor.schemas.ITHeaderInfo;
import com.oracle.bpel.sensor.schemas.ITSensorAction;
import com.oracle.bpel.sensor.schemas.ITSensorActionData;
import com.oracle.bpel.sensor.schemas.ITSensorData;
import org.w3c.dom.Element;
public class MyCustomSensorPublisher implements DataPublisher{
public MyCustomSensorPublisher() {
}
public void publish(ITSensorAction action,ITSensorActionData actiondata,Element xml) {
ITHeaderInfo header =actiondata.getHeader();
ITSensorData data=actiondata.getPayload();
System.out.println("Sensor "+header.getSensor().getSensorName()+" fired for BPEL Process "+header.getProcessName());
System.out.println("Sensor Data "+xml.toString());
}
}

2. Open the BPEL file and add the sensor.
Right click on the activity and select Create - Sensor





Oracle SOA Suite – Scheduling the composites using Quartz scheduler.

Oracle SOA Suite – Scheduling the composites using Quartz scheduler.

This blog will explain the approach to schedule the Oracle SOA Suite composites using the Quartz scheduler.

Approach to schedule the Oracle SOA Suite 11g composites 

Create the ADF binding to the composite.xml

Open the composite xml


Copy the service section and give a unique name e.g. bpelhelloworld_client_adf and also make sure the ServiceName specified is correct.


Copy the client partnerlink wire and edit the name of the copied wire as adf service name specified in the previous step.






Thursday, December 1, 2011

Oracle SOA Suite - Using the EJB Adapter to invoke the EJB's deployed in weblogic server

Oracle SOA Suite - Using the EJB Adapter to invoke the EJB's deployed in weblogic server:

We can use the EJB Adapter to expose the EJB remote interface as a service or to invoke the EJB as a reference.

This blog will explain how to use the EJB Adapter to invoke the EJB deployed in the weblogic server as a reference.

I have created a sample EJB (EmployeeDetailsSessionBean), which will be invoked from Composite, to return the employee details.

Refer the sample attached.

Steps:


  • Create a jar file e.g. RemoteInterface.jar including EJB Remote class and the Bean classes.

  • Create a SOA Composite with BPEL and add the EJB Service to the reference section.



Wednesday, November 30, 2011

Resetting Weblogic Server Admin Password

Resetting Weblogic Server Admin Password:

Steps to reset the admin password of weblogic server.

  • cd <DOMAIN_HOME>/security
  •  Rename DefaultAuthenticatorInit.ldift file to DefaultAuthenticatorInit.ldift_BKP
  • Set the Environment - <DOMAIN_HOME>/bin/setDomainEnv.cmd
  • java -cp <WLS_HOME>;/server/lib/weblogic.jar:$CLASSPATH weblogic.security.utils.AdminAccount NewAdminUser NewAdminPassword . (Note the . at the end of the command)
  Make sure you are running the above command is executed from    DOMAIN_HOME>/security,   if you are executing the command from other location copy the   DefaultAuthenticatorInit.ldift file created in the current location to <DOMAIN_HOME>/security
e.g java -cp C:\Oracle\MiddlewareSOA\wlserver_12.1\server\lib\weblogic.jar;%CLASSPATH% weblogic.security.utils.AdminAccount albin albin123  
  • Move data directory under $DOMAIN_HOME/servers/<serverName>/datato another directory like data.bak
  •  Edit user name and password in the following file - <DOMAIN_HOME>/servers/<Server Name>/security/boot.properties
  • Restart the admin server


Adding main class and jar files to Class-Path in manifest through ANT script

Adding main class and jar files to Class-Path in manifest through ANT script

The below ANT script will help us to add main class and jar files to Class-Path in manifest of the JAR file.

<?xml version="1.0" encoding="iso-8859-1"?>
<project name="jar with libs" default="compile and build" basedir=".">

<target name="compile and build">
<delete dir="bin" />
<mkdir dir="bin"/>

<!-- copy the JARs that should be added to MANIFEST class-path to "bin" directory -->
<copy todir="bin">
<fileset dir="." includes="**/lib/*.jar" />
</copy>

<!-- creates your jar with the contents inside "bin" (now with your .class and .jar dependencies) -->
<jar destfile="SampleJar.jar" basedir="bin" duplicate="preserve">
<manifest>
<!-- Who is building this jar? -->
<attribute name="Built-By" value="Albin I" />
<!-- Information about the program itself -->
<attribute name="Implementation-Vendor" value="Company" />
<attribute name="Implementation-Title" value="Albin" />
<attribute name="Implementation-Version" value="1.0.0beta1" />
<attribute name="Class-Path" value="lib/bpm-services.jar lib/ldapjclnt11.jar lib/ojdbc14.jar lib/xmlparserv2.jar"/>

<!-- this tells which class should run when executing your jar -->
<attribute name="Main-class" value="com.import.ImportUtility" />
</manifest>
</jar>
</target>

</project>