Invoke a Web service with Eclipse BPEL designer and Apache ODE

BPEL’s WS invocation

  1. Create a new BPEL project named “BPEL_WS” by selecting File→New→Others→BPEL 2.0→BPEL Project. Select Next. Type the project name asBPEL_WS and select the Target Runtime as Apache ODE 1.x Runtime. Click Finish.
  2. Create a new BPEL process file named WS_Invocation by right clicking on the BPEL_WS/bpelContent folder, select New→Others→BPEL 2.0→New BPEL Process File. Click Next. Fill in BPEL Process Name the string WS_Invocation, and in the Namespace the string http://ws.invocation.tps. Select the Template as Synchronous BPEL Process. Click Next.

  3. Modify the Service Address as http://localhost:8080/ode/processes/WS_Invocation. Click Finish.
  4. Click and drag an Invoke action from the Palette to the BPEL process and name it as InvokePingPongService.
  5. Insert two other Assign actions before and after the Invoke action named AssignInputToSOAPRequest and AssignOutPutToResult.

  6. To invoke a web service, you have to know its description. In our example, we will invoke a PingPong web service and Here is its description file. Download it and copy it to your project.
  7. Now, click on InvokePingPongService, in the Properties view, select Details→Partner Link→Create Global Partner Link. Name it as PingPongPL. Click OK.
  8. A pop-up dialog appears. In this step, you have to select the Partner Link Type Structure which is the PingPong service. Select Add WSDL button. Then select the option From Project. Select the PingPong interface as the Partner Link Type Structure. Click OK.

  9. Type the Partner Link Type Name as PingPongPLT. Click Next.
  10. Type the Role Name as PingPongPLRole, select the PingPong Port Type. Click Next.
  11. Ignore the second Role of the Partner Link. Click Finish.
  12. Continue with the Details of the InvokePingPongService action. Select the Operation echoInput at the Quick Pick area. Other two variables are automatically generated which are PingPongPLRequest and PingPongPLResponse.

  13. Click on the AssignInputToSOAPRequest action. In the Properties view, select Details→New and assign the input→payload→input toPingPongPLRequest→Parameters→input. A pop-up dialog appears to ask you about the variable initiation. Select Yes.

  14. By the same way, select the AssignOutPutToResult action and assign the PingPongPLResponse→parameters→echoInputReturn to theoutput→payload→result.

  15. Save the files. Right click on the BPEL_WS/bpelContent, select New→Others→BPEL 2.0→Apache ODE Deployment Descriptor. Click Next. Verify the BPEL Project name as /BPEL_WS/bpelContent. Click Finish.
  16. Now you have the file deploy.xml in your project. Right click on this file. Select Open With→ODE Deployment Descriptor Editor. At the Inbound Interfaces (Services), Partner Link is the client, select the Associated Port as WS_InvocationPort and click on other field. Eclipse will automatically fill in other fields.
  17. At the Outbound Interfaces (Invokes), Partner Link is PingPongPL, select the Associated Port as PingPong and click on other field to fulfill it.

  18. Save file and open the Server view, right click on the Ode v1.x Server at localhost, select Add and Remove Projects. Select theBPEL_WS/WS_Invocation.bpel in the Available projects box and click Add. Then, click Finish.
  19. Start the ODE server to deploy the WS_Invocation BPEL process on the server. We will use the Eclipse’s Web Services Explorer to test our application.
  20. Right click on the WS_InvocationArtifacts.wsdl file. Select Web Services→Test with Web Services Explorer.
  21. Select the operation process. Then, type Hello PingPong Service in the input textbox. If your deployment was successful, you will get the string like the folowing in the SOAP response.

Advertisements

BPEL structured activities: While with Eclipse -5-

BPEL’s While loop

  1. Create a new BPEL project named “BPEL_While” by selecting File→New→Others→BPEL 2.0→BPEL Project. Select Next. Type the project name asBPEL_While and select the Target Runtime as Apache ODE 1.x Runtime. Click Finish.
  2. Create a new BPEL process file named WhileSample by right clicking on the BPEL_While/bpelContent folder, select New→Others→BPEL 2.0→New BPEL Process File. Click Next. Fill in BPEL Process Name the string WhileSample, and in the Namespace the string http://while.bpel.tps. Select the Template as Synchronous BPEL Process. Click Next.
  3. Open WhileSample.bpel file. Click and drag the While control from the Palette to the process, between the receiveInput and replyOutput actions. Drag an Assign action before the While activity, an Assign into the While and another Assign before the replyOutput.
  4. At the Variables view, click on the Add(+) symbol to add a new variable. Name it as iterator and add another variable named temp.
  5. Click on the variable iterator, in the Properties view, select Details→Browse. Select the type of this variable is{http://www.w3.org/2001/XMLSchema}int. Keep the Namespace mapping as ns1. Select Ok.
  6. Select the variable temp and set its type as ns1:string.
  7. Click on the Assign action, in its Properties view, select Details→New. Assign the fix value 0 to the variable iterator.
  8. Then, select New again to assign the variable input→payload→input to temp.
  9. Select the While loop action. In the Details of its Properties, set the condition of the while loop as $iterator<5.
  10. At the Assign1 action, assign the expression $iterator+1 to the iterator.
  11. Click New again to add another expression which assign concat($temp,” ”,$input.payload/tns:input) to the variable temp.
  12. Click on the Assign2 action, assign the variable temp to output→payload→result.
  13. Save the process design.
  14. Save the files. Right click on the BPEL_While/bpelContent folder, select New→Others→BPEL 2.0→Apache ODE Deployment Descriptor. Click Next. Verify the BPEL Project name as /BPEL_While/bpelContent. Click Finish.
  15. Open the deploy.xml file. And select the Associated port with the Partner Link client is WhileSamplePort.
  16. Save the file and open the Server view, right click on the Ode v1.x Server at localhost, select Add and Remove Projects. Select the BPEL_While in the Available projects box and click Add. Then, click Finish.
  17. Start the ODE server and use the Eclipse’s Web Services Explorer to test our application. If you deploy the process successfully, you will see the result like the following:

BPEL structured activities: Flow With Eclipse -4-

BPEL’s Flow activity

  1. Create a new BPEL project named “BPEL_Flow” by selecting File→New→Others→BPEL 2.0→BPEL Project. Select Next. Type the project name as BPEL_Flow and select the Target Runtime as Apache ODE 1.x Runtime. Click Finish.
  2. Create a new BPEL process file named FlowSample by right clicking on the BPEL_Flow/bpelContent folder, select New→Others→BPEL 2.0→New BPEL Process File. Click Next. Fill in BPEL Process Name the stringFlowSample, and in the Namespace the string http://flow.bpel.tps. Select the Template as Synchronous BPEL Process. Click Finish.
  3. Modify the Service Address as http://localhost:8080/ode/processes/FlowSample (suppose that your Tomcat environment is running on port 8080). Click Finish.
  4. Open FlowSample.bpel file. Click and drag the Flow control from the Palette to the process, between the receiveInput and replyOutput actions. Drag two Sequence controls and two Assign actions to the Flow. Insert another Assign above the replyOutput action. 
  5. At the Variables view, click on the Add(+) symbol to add two new variables. Name them as flow1 and flow2
  6. Click on the variable flow1, in the Properties view, select Details→Browse. Select the type of this variable is {http://www.w3.org/2001/XMLSchema}string. Keep the Namespace mapping as ns1. Select Ok
  7. Select the variable flow2 and set its type as ns1:string.
  8. Click on the Assign action in the Sequence1, in its Properties view, select Details→New. Assign the fix value ” is executed by the flow 1” to the variable flow1
  9. By the same way, at the Assign1 action, assign the string ” and the flow 2.” to the variable flow2.
  10. At the Assign3 action, add the expression concat($input.payload/tns:input,$flow1,$flow2) to the variable output→payload→result. A pop-up dialog appears, select Yes
  11. Save the files. Right click on the BPEL_Flow/bpelContent folder, select New→Others→BPEL 2.0→Apache ODE Deployment Descriptor. Click Next. Verify that the name of BPEL Project is /BPEL_Flow/bpelContent. Click Finish.
  12. Open the deploy.xml file. And select the Associated port with the Partner Link client is FlowSamplePort.
  13. Save file and open the Server view, right click on the Ode v1.x Server at localhost, select Add and Remove Projects. Select the BPEL_Flow in the Available projects box and click Add. Then, click Finish.
  14. Start the ODE server and use the Eclipse’s Web Services Explorer to test our application. If you deploy the process successfully, you will see the result like the following: 

     

Installing BPEL designer and Apache ODE on Eclipse

Installing Eclipse BPEL designer

  1. Suppose that you have already downloaded and installed your Eclipse > v3.6.2(Helios,or Indigo), version for Java EE Developers and JDK (version > 1.5).
  2. Open the Eclipse, go to the menu Help→Install New SoftWare.
  3. Click on the button Add and define a new Eclipe update site with the location:
    http://download.eclipse.org/bpel/site/
  4. Now you have the update-site of BPEL available on the eclipse. Select the check box to BPEL Visual Designer and click on the button Next.

  5. Follow the installation windows, you will now have your BPEL installed on Eclipse. Note that: the BPEL dependencies(WTP, EMF, GEF, JEM) should be installed before the BPEL designer. Fortunately, with Eclipse Helios for JavaEE, you have all.
  6. After finishing the installation, restart it.
  7. To verify the installation was successful, after the restart, click on File→New→Other, you will see the BPEL 2.0 is on the list.

The BPEL designer is now ready to use. However, to run the BPEL process, you should have the server’s environment. Now, we are going to install the Apache ODE for the BPEL deployment.

Installing Apache ODE

  1. Download and extract the latest ODE from the Apache web site. The current stable version is the ODE 1.3.5.
  2. Inside the “apache-ode-war-1.3.5” folder, you will see an “ode.war” file. Deploy this file on your Tomcat server.
  3. The simple way to do this is extracting the “ode.war” file to get the ode folder.
  4. Copy this ode folder to your TOMCAT_DIR/webapps directory.
  5. That’s all.

Now, you have finished the installation steps. Now, you are going to set up the ODE server on Eclipse to run the BPEL application.

Setting up the ODE server on Eclipse

  1. Show the “Servers” view by selecting the menu Windows→Show View→Servers.
  2. Right click on the empty space of the “Servers” view, select New→Server.
  3. Leave the server host name as localhost and select the server type as the Apache→Ode v1.x Server. Rename the server’s name if you want. In my installation, I keep the default name. Then click on the button Next.

  4. Select the JRE as the Default JRE which was integrated in the Eclipse. Set the path to the ODE’s home directory and the Tomcat directory. Then, set the Tomcat’s port as the port in its configuration file. The default port is 8080.

    Note that: the ODE Runtime configuration above can also be added or editted using the menu Windows→Preferences→Server→Runtime Environments.

  5. Click Finish. You now have the ODE server which is ready to run on the Eclipse. You can see this server on the Server View.
  6. Now, you should test the server’s configuration by right click on the ODE server entry and select Start. Or you can click on the Start button on the Server View. If the server is sucessfully started, you will see the status like this.

  7. If you are using Tomcat v.6 or v.7, you probably get the error

    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory
      at org.apache.catalina.startup.Bootstrap.<clinit>(Bootstrap.java:54)
    Caused by: java.lang.ClassNotFoundException: org.apache.juli.logging.LogFactory
      at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
      at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336)
      ... 1 more
    Could not find the main class: org.apache.catalina.startup.Bootstrap. Program will exit.
  8. This error occurs maybe because it misses the tomcat-juli.jar in the Launch environment.
  9. To fix this, double click on the installed Ode v1.x Server in the Server View to see the configuration.

  10. Click on Open launch configuration → Classpath tab → Add External JARs → [your TOMCAT_DIR]\bin\tomcat-juli.jar. Then Ok.

  11. Now try to start your ODE server in the Server View.
  12. Terminate the server by clicking on the Stop button or right click on the server and select Stop. Every thing is ready now for the first BPEL program.