Introduction

This tutorial focuses on deploying a BPEL process on the Apache ODE.

BPEL, i.e., business process execution language, is written in XML. It is used to achieve automatic process execution, and also known as WSBPEL and BPEL4WS. For more details, please refer to BPEL-Wikipedia.

In this tutorial, we need these tools:

OK, here we go.

Tutorial

Firstly, download the Eclipse Java EE, JDK and install it. There are many instructions about this step, so it is ignored here.

Install Tomcat and add it in the Eclipse

Image

Choose “Tomcat v8.5 Server” and click “Next”. Click “Browse…” and choose the Tomcat directory we have created in the first step. And click “Next”… “Finish”.

Install the Eclipse BPEL plug-in

Open Eclipse, and click the “Help”-“Install New Software…”. Input “http://www.mirrorservice.org/sites/download.eclipse.org/eclipseMirror/bpel/site/1.0.5/”, and then choose “Eclipse BPEL Designer” and click “Next”…“Accpet xxx” and “Finish”.

Image

Install Apache ODE and add it in the Eclipse

Image

Image

Image

Image

Image

Click “Open launch configuration” and choose “Classpath”.

Image

Click “User Entries”, then click “Add External JARs…” and choose the “Tomcat/bin/tomcat-juli.jar” and “Open”, “OK”.

Image

Create BPEL project in Eclipse

Image

Image

Image

Image

Write a simple BPEL project

After finishing the former steps, we have created a BPEL project. In this part, we focus on writing a simple BPEL process.

Image

Image

Image

Image

Image Image

Image

Image

After this, the Eclipse will prompt “if you need a initializer for these assignments”. Choose “Yes”.

Image

In this step we assign the BPEL input to the parameters of the function we invoke. But be careful, sometimes the Eclipse will not generate initializer automatically although we have choosed “yes” in the former step. Under this circumstance, we need to initialize it manually. Just edit the XML file like the picture. Choose “Fixed Value” and write “ns: and ns:". And click parameters under the Request in the "To" variable window. It means use the fixed value to initialize the parameters.

Image

Image

Image

Image

Image

Image

Test BPEL by Java

We can also test the BPEL process by Java. In fact, it is the same way to invoke a wsdl process.

import javax.xml.namespace.QName;
import org.apache.axiom.om.OMAbstractFactory;  
import org.apache.axiom.om.OMElement;  
import org.apache.axiom.om.OMFactory;  
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.OMNode;
import org.apache.axis2.AxisFault;  
import org.apache.axis2.addressing.EndpointReference;  
import org.apache.axis2.client.Options;  
import org.apache.axis2.client.ServiceClient;  
import org.apache.axis2.rpc.client.RPCServiceClient;
OMElement result = null;  
try {  
    String url = "http://localhost:8080/ode/processes/BPELSayHello?wsdl"; //BPEL or WSDL address
    Options options = new Options();   
    EndpointReference targetEPR = new EndpointReference(url);  
    options.setTo(targetEPR);  

    ServiceClient sender = new ServiceClient();  
    sender.setOptions(options);  

    OMFactory fac = OMAbstractFactory.getOMFactory();  
    String tns = "http://fabu"; //the same as the BPEL or WSDL namespace

    OMNamespace omNs = fac.createOMNamespace(tns, "");

    OMElement method = fac.createOMElement("BPELSayHelloRequest", omNs); //which function you want to invoke

    OMElement symbol1 = fac.createOMElement("input", omNs); //define the parameter name
    symbol1.addChild(fac.createOMText(symbol1, "123")); //define the parameter value
    method.addChild(symbol1);

    method.build();
    System.out.println(method);
    result = sender.sendReceive(method);

    //Get the result by loop
    Iterator iterator =  result.getChildElements();
    while (iterator.hasNext()) {
      OMElement omNode = (OMElement) iterator.next();
      Iterator iterator2 = omNode.getChildElements();
      while(iterator2.hasNext()) {
        OMElement omNode2 = (OMElement) iterator2.next();
        System.out.println(omNode2.getLocalName() + ": " + omNode2.getText());
      }
      System.out.println();

    }

    System.out.println(result);  

} catch (AxisFault axisFault) {  
    axisFault.printStackTrace();  
}