Oracle BPEL: Modify files by using Base64decode & Base64encode in a BPEL process

In this blog I’ll show you have to read a file content in BPEL adding header and footer to the file.

To do this you need to decode the file first by using Base64decode in an embedded Java (see process activities)

First create a BPEL process and make sure that you have a simple process which can read a file by using file adapter from the server and can also write(by using file adapter) it to the server (See other blogs how to create such a process).

Your process will look like this:

Now we gonna do the real work.

1. To simplify the idea, we gonna add two extra variables to the process(you can also work directly with Read output parameter):

v_inputData and v_outputData of the type opaque:

2. once you have the variables you can assign the syncRead output parameter to v_inputData

3. now you can add a Java_Embedding activity to your process:

add the following java code

// Decode the file to be able to add a header text to the file. You can put in your java code calculations and other stuff as well. //

addAuditTrailEntry(“Base64decode started”);
String input_data=null;
try {
input_data = ((oracle.xml.parser.v2.XMLElement)getVariableData(“v_inputData”,”opaque”,”/ns4:opaqueElement”)).getFirstChild().getNodeValue();
//Replace the | char in the file
String decodedString = Base64Decoder.decode(input_data);

setVariableData(“v_outputData”,”opaque”,”/ns4:opaqueElement”,” Header tekst\n” + decodedString);
} catch (Exception e) {
addAuditTrailEntry(“Base64decode Exception: ” + e.getMessage());
} addAuditTrailEntry(“Base64decode ended”);

//Encode the file to let the fileadapter server be able to write the file to the sever//
addAuditTrailEntry(“Base64encode started”);
String input_str = null;
try {
input_str = ((oracle.xml.parser.v2.XMLElement)getVariableData(“v_outputData”,”opaque”,”/ns4:opaqueElement”)).getFirstChild().getNodeValue();
addAuditTrailEntry(“Base64encode input_str=”+input_str);
String encoded = null;
encoded = Base64Encoder.encode(input_str);
addAuditTrailEntry(“Base64encode encoded=”+encoded);
} catch (Exception e) {
addAuditTrailEntry(“Base64encode Exception: “+e.getMessage());
addAuditTrailEntry(“Base64encode ended”);

4. remember that Invoke_2_Write_InputVariable is the invoke input of the write file adapter.

Deploy your application and test it. for any question drop me an email.

End op the this pot.

Oracle BPM-BPEL process with correlations

This blog describes a sample application for a POC about using correlations in BPM and BPEL.

Create a SOA project


Add BPM technology to your project


Create a BPM process with these components


Create BPEL component. Select “Based on WSDL”.


Add 2 input messages to your process. One to start the process and the other to continue the process.


Expose as a SOAP service


Add a Receive action to you process link it to client partnerLink.


Assign the fromAdapter to the Receive action


Create Correlation set


Add property to the correlationSet


Select de type as String


Add 2 Aliases to the property one of message type startProcess(as created before) and the other as fromAdaprt(as created before)


Add correlation to receiveInput in your BPELprocess and set initiate “Yes”


Add correlation to Receive in your BPELprocess and set initiate “no”


Add a request message type to the BPEL WSDL


Back to BPM process define input string and assign it


Configure the ThrowEvent


Assign input message


deploy and test your project.

Run process.service, you will see that it will have status running


Run bpelprocess1_client.service with the same input as process.service. don’t forget to select the correct operation!


Deploy and test your project.

· Start the BPM process.
· User soapUI to send input to the Master process.
· Master process saves input in the database and starts the correlation process.
· You should see in the BPM process that the process gets input.