Wednesday, February 9, 2011

Invoking SOA Suite 11g Composite via Direct Binding

Scenario: I want to invoke a SOA Composite (essentially an Async BPEL process) via Direct Binding.

My starting point for this was Edwin's blog (which I can highly recommend!!!)-

However, I had issues with namespaces in my complex payload, requiring me to switch to the Oracle XML parser --> thus this post!

I'm using the following xsd for my payload.

Step 1 - Create a SOA Composite that includes an async BPEL process with input/output types set to the order defined above. Do not expose as a SOAP Service.

Step 2 - Add a Direct Binding to the Exposed Services lane and point to the WSDL of the BPEL process.

Step 3 - Add an Assign (Input 2 Output) to the BPEL process.

Step 4 - Wire the Direct Binding to the BPEL Process.
In the BPEL designer, delete the processorders_client partner link and use the Direct Binding instead.

Step 5 - Deploy and go to http://localhost:7001/soa-infra

Step 6 - Create a new project in your JDev app e.g.
InvokeDirectBinding-Client and add the following libraries to it.

Step 7 - Add a Java class to the project and cut and paste in the following code. Then test. Note the use of the Oracle XML parser here, I had some issues with the default one... Thanks Silviu / Santosh for the tip.

package invokedirectbin;


import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
import java.util.UUID;

import javax.naming.Context;

import oracle.soa.api.JNDIDirectConnectionFactory;
import oracle.soa.api.PayloadFactory;
import oracle.soa.api.XMLMessageFactory;
import oracle.soa.api.invocation.DirectConnection;
import oracle.soa.api.invocation.DirectConnectionFactory;
import oracle.soa.api.message.Message;
import oracle.soa.api.message.Payload;

import oracle.xml.parser.v2.DOMParser;
import oracle.xml.parser.v2.XMLPrintDriver;

import org.w3c.dom.Element;

import org.xml.sax.InputSource;

public class InvokeComposite {
public InvokeComposite() {

public void StartAsyncViaDirectBinding(){
// create a direct connection to the composite
Hashtable jndiProps = new Hashtable();
jndiProps.put(Context.PROVIDER_URL, "t3://localhost:7001/soa-infra");
jndiProps.put(Context.SECURITY_PRINCIPAL, "weblogic");
jndiProps.put(Context.SECURITY_CREDENTIALS, "welcome1");
jndiProps.put("dedicated.connection", "true");

Locator locator = null;
try {
DirectConnectionFactory factory = JNDIDirectConnectionFactory.newInstance();
String serviceAddress = "soadirect:/default/InvokeDirectBinding!1.0/DirectBinding2ProcessOrders";
DirectConnection dc = factory.createConnection(serviceAddress,jndiProps);

// Sample payload from em is as follows -




String inputPayload =
"\n" +
"RenateC\n" +
"rc@localhost\n" +
"123456\n" +
"iPad\n" +
"100\n" +
"500\n" +
"none\n" +
"50000\n" +
"pending\n" +
"none\n" +
System.out.println("Input = " +"\n" + inputPayload);
// parse using the Oracle XML parser.
// Thanks Silviu!
oracle.xml.parser.v2.DOMParser op = new DOMParser();
op.parse(new InputSource(new StringReader(inputPayload)));

// just a print to check it
XMLPrintDriver pd = new XMLPrintDriver(System.out);

Map partData = new HashMap();
partData.put("payload", op.getDocument().getDocumentElement());

// Create the Message and pass in the payload
Payload payload = PayloadFactory.createXMLPayload(partData);

Message request = XMLMessageFactory.getInstance().createMessage();

// Define conversation ID
String uuid = "uuid:" + UUID.randomUUID();
System.out.println("uuid = "+ uuid);
request.setProperty(request.CONVERSATION_ID, uuid);

// Invoke..."process", request);

} catch (Exception e) {



Payload displayed incorrectly above so here it is again -

Anyway the source code is available at


Anonymous said...

nice post..realy helpful

Anonymous said...

nice post

Anonymous said...


Great post as usual. What exactly are the benefits of direct binding over normal SOAP bindings?
Would be helpful if you can also suggest the use cases for using this type of invocation.

Also, SOA offers concept of local optimization. Is this direct binding related in any way to local optimization?


Niall Commiskey said...

Direct binding useful for passing transaction and security contexts, not for speed - as the name "direct" might imply.