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: 

     

BPEL structured activities: If-Else with Eclipse -3-

  1. Create a new BPEL project named “BPEL_IfElse” by selecting File→New→Others→BPEL 2.0→BPEL Project. Select Next. Type the project name asBPEL_IfElse and select the Target Runtime as Apache ODE 1.x Runtime. Click Finish.
  2. Create a new BPEL process file named IfElseSample by right clicking on the BPEL_IfElse/bpelContent folder, select New→Others→BPEL 2.0→New BPEL Process File. Click Next. Fill in BPEL Process Name the string IfElseSample, and in the Namespace the string http://ifelse.bpel.tps. Select the Template as Synchronous BPEL Process. Click Next.
  3. Modify the Service Address as http://localhost:8080/ode/processes/IfElseSample (suppose that your Tomcat environment is running on port 8080). Click Finish.
  4. Open IfElseSample.bpel file. Click and drag the If control from the Palette to the process, between the receiveInput and replyOutput actions.
  5. Drag an Assign action into the If and drag the replyOutput below the Assign. A sequence is automatically created.

  6. Right click on the If activity, select Add Else. Drag one Assign and one Reply action to the Else branch.

  7. Select the If activity, in the Properties view, select Details→Create New Condition and edit the condition as $input.payload/tns:input=“John”.

  8. Click on the Assign action, in its Properties view, select Details→New. Assign the fix value “Hello John” to the variable output→payload→result. A pop-up dialog appears asking you about the variable initiation. Select Yes. In case the pop-up dialog does not appear, you can do the following steps to initialize the result variable: change the operation to “assign from a Variable to Variable”; then, assign the input variable to output→payload→result; the pop-up dialog should appear; then you change the operation back to “assign from a Fix value to a Variable”.

  9. By the same way, at the Assign1 action, assign “You are not John” to the output-payload-resultRemember to initialize the variable result before assigning this string.
  10. Click on the Reply action, in the Detail tab, at the Quick Pick, select IfElseSample→process→IfElseSampleResponseMessage-Payload→result to assign the result to the output variable.

  11. Save the process design. Right click on the BPEL_IfElse/bpelContent, select New→Others→BPEL 2.0→Apache ODE Deployment Descriptor. ClickNext. Verify the BPEL Project name as /BPEL_IfElse/bpelContent. Click Finish.
  12. Open the deploy.xml file. And select the Associated port with the Partner Link client is IfElseSamplePort.
  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_IfElse 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:

     

BPEL structured activities: Pick with Ecplipse -2-

BPEL’s Pick activity

  1. Create a new BPEL project named “BPEL_Pick” by selecting File→New→Others→BPEL 2.0→BPEL Project. Select Next. Type the project name as BPEL_Pick and select the Target Runtime as Apache ODE 1.x Runtime. Click Finish.
  2. Create a new BPEL process file named PickSample by right clicking on the BPEL_Pick/bpelContent folder, select New→Others→BPEL 2.0→New BPEL Process File. Click Next. Fill in BPEL Process Name the stringPickSample, and in the Namespace the string http://pick.bpel.tps. Select the Template as Synchronous BPEL Process. Click Next.
  3. Modify the Service Address as http://localhost:8080/ode/processes/PickSample (suppose that your Tomcat environment is running on port 8080). Click Finish.

  4. Open the PickSampleArtifacts.wsdl file in your project. Right click on the PickSample Port Type. Select Add Operation.
  5. Rename the new operation as sayGoodbye . Rename the existing operation from process to sayHello.

  6. Open the Outline→Bindings→PickSampleBinding. In the Properties view. Click Generate Binding Content... Keep default declaration, select Overwrite existing binding InformationFinish.

  7. Open the PickSample.pbel file to design the process. Click and drag the Pick activity from the Palette to the process before the receiveInput activity.
  8. In the Details tab of the Pick activity, select the option Create a new Process instance if one does not already exist.
  9. Remove the receiveInput activity and move the replyOutput activity to the OnMessage event, inside the Pick. Click and drag an Assign activity to the process, before the replyOutput. A Sequence is automatically created.

  10. Click on the OnMessage activity. In the Details tab, select the operation sayHello.

  11. Right click on the Pick activity. Select Add OnMessage. In the Details tab, select the operation sayGoodbye. Add an Assign activity and a Reply activity to the sayGoodbye branch.

  12. Click on the Reply activity of the sayGoodbye branch, in the Details tab, assign the PickSample→sayGoodbye→sayGoodbyeResponse→parameters→out to the clientResponse variable.

  13. The same way with the replyOutput activity, assign PickSample→sayHello→PickSampleResponseMessage→payload→result to the output variable.
  14. Click on the Assign activity, select Details→New. Assign the expression concat(“Hello ”,$input.payload/tns:input) to the output→payload→result variable. A pop-up dialog appears asking you about the variable initiation. Select Yes.

  15. The same way, at the Assign1 activity, assign the expression concat(“Goodbye ”,$clientRequest.parameters/tns:in) to the clientResponse→parameters→out variable.
  16. It’s now finish the design part. Verify that there is no error in the dessign. We move to the service declaration and registration.
  17. Right click on the BPEL_Pick/bpelContent folder, select New→Others→BPEL 2.0→Apache ODE Deployment Descriptor. Click Next. Verify the BPEL Project name as /BPEL_Pick/bpelContent. Click Finish.
  18. Open the deploy.xml file. And select the Associated port with the Partner Link client is PickSamplePort.
  19. 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_Pick in the Available projects box and click Add. Then, click Finish.
  20. Start the ODE server and use the Eclipse’s Web Services Explorer to test our application. You will see two operations sayHello and sayGoodbye that you can select to use. Depending on the operation you select, BPEL will execute the respective process.