Invoke a Web service with Eclipse BPEL designer and Apache ODE
In this tutorial we will see how to invoke a remote web service using the Invoke action of the Eclipse BPEL Designer. The remote service used in this tutorial is the PingPong service, which returns the client exactly the input string together a the session ID.
Tools: Eclipse 3.6, BPEL Designer 0.5.0 Plugin, Tomcat 7.0.53, ODE 1.3.5
BPEL's WS invocation
Create a new BPEL project named “BPEL_WS” by selecting File→New→Others→BPEL 2.0→BPEL Project. Select Next. Type the project name as BPEL_WS and select the Target Runtime as Apache ODE 1.x Runtime. Click Finish.
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. Click Next.
Select the Template as Synchronous BPEL Process and modify the Service Address as http://localhost:8080/ode/processes/WS_Invocation. Click Next→ Finish.
Open WS_InvocationArtifacts.wsdl. Right click on WS_InvocationPort. Select show properties and make sure that the Address is http://localhost:8080/ode/processes/WS_Invocation.
Click and drag an Invoke action from the Palette to the BPEL process and name it as InvokePingPongService.
Insert two other
Assign actions before and after the Invoke action named
AssignInputToSOAPRequest and
AssignOutPutToResult.
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.
Now, click on InvokePingPongService, in the Properties view, select Details→Partner Link→Create Global Partner Link. Name it as PingPongPL. Click OK.
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.
Type the Partner Link Type Name as PingPongPLT. Click Next.
Type the Role Name as PingPongPLRole, select the PingPong Port Type. Click Next.
Ignore the second Role of the Partner Link. Click Finish.
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.
Click on the
AssignInputToSOAPRequest action. In the
Properties view, select
Details→New and assign the
input→payload→input to
PingPongPLRequest→Parameters→input. A pop-up dialog appears to ask you about the variable initiation. Select
Yes.
By the same way, select the
AssignOutPutToResult action and assign the
PingPongPLResponse→parameters→echoInputReturn to the
output→payload→result.
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.
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.
At the Outbound Interfaces (Invokes), Partner Link is
PingPongPL, select the Associated Port as
PingPong and click on other field to fulfill it.
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_WS/WS_Invocation.bpel in the Available projects box and click Add. Then, click Finish.
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.
Right click on the WS_InvocationArtifacts.wsdl file. Select Web Services→Test with Web Services Explorer.
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.
Done.
Exercices
Create another BPEL process which invoke the simple Sum service, which returns the sum of two integers.
Here is the WSDL file of this service.
Create a BPEL process to invoke the String Analysis service which is described by the
WSDL file. This service analyzes the input string and returns some information related to the string, including the number of characters, the number of words and the longest word.
Create a BPEL process using the Simple Calculator service to compute the formula f=(a+b)*h.
Here is the description service.
Tip: use two invoke actions.
There are two other services which compute the
area of a
rectangle and an
ellipse. Now, use these services and the
Simple Calculator service above to create a PBEL process to compute the area limited by a rectangle and an ellipse inscribed in that rectangle.
Tip: use three invoke actions.
Rectangle Computation Service |
Ellipse Computation Service |
Problem |
|
|
|
Input=(h,b) |
Input=(a,b) |
Red area = ? |
Resources for this tutorial
Back to top