Introduction
The example below shows how to invoke an existing/external web service in BPEL. This example uses Eclipse, Eclipse BPLE designer Plug-In and Apache ODE.
Background
Using the Code
There are two parts in this article:
- Part A: Prepare a Web Service
- Part B: Invoke this web service in BPEL
Part A: Prepare Web Service
- Create a web service “
DoSomethingWebService
”, which has only one class “DoSomething
” (under namespace “ws.example
”) with only one method “doSomething
”. You can use the bottom-up approach to build this web service. Please see this link.
package ws.example;
public class DoSomething {
public String doSomething(String myinput)
{
System.out.println("doSomething is called");
return "doSomething is called ";
}
}
- Check the generated WSDL file, the service name is “
DoSomethingService
”, Port “DoSomething
”, binding address is http://localhost:8080/DoSomethingWebService/services/DoSomething.
Figure 1: "DoSomethingService" Web Service
- Export the service to a war file and deploy it under $TomcatHome/webapps. If you like to, export and deploy the test client also, it is good for testing. Please see this link.
Part B: Invoke this Web Service in BPEL
- Prepare ODE and BPEL Plug-In and create a BPEL project “
InvokeWebServiceProj
” and a synchronous BPEL process “Caller
” under namespace “http://MyTest.com/Test”. Please see this link. - Import DoSomething.wsdl into the project and create a partner link “
DSLink
” of type “DSLinkType
”, Partner Role of “DSProvider
”. Please see this link.
Figure 2: “DSLinkType”
- Add
Assign
, Assign1
and Invoke Block in “Caller
” process:
Figure 3: "Caller" BPEL Process
- Edit Invoke Block to call “
doSomething
”.
Figure 4: "Invoke" Block
- Initialize “
DSLinkRequest
” from “Assign
” block, choose From->Fixed Value and To->DSLinkRequest>parameters. The fixed value is described as:
<xsd:doSomething xmlns:xsd="http://example.ws">
<xsd:myinput/>
</xsd:doSomething>
Figure 5: Initialize “DSLinkRequest”
- Set the input value for “
doSomething
” method. Choose From->Variable->input->payload->input and To->Variable->DSLinkRequest->parameters->myinput.
Figure 6: Set “myinput” for “DSLinkRequest”
- Initialize “
output
” from “Assign1
” block. Choose From->Fixed Value and To->output>payload. The fixed value is described as:
<tns:CallerResponse xmlns:tns="http://MyTest.com/Test">
<tns:result/>
</tns:CallerResponse>
Figure 7: Initialize “output”
- Set the output value for “
Caller
” process. Choose From->Variable->DSLinkResponse
->parameters->dosomethingReturn
and To->Variable->output->payload->result.
Figure 8: Set “result” for “output”
- Edit the Caller.wsdl generated, so that a “
CallerService
” of port “CallerPort
” is bound to the “Caller
” process with the address “http://localhost:8080/ode/processes/Caller” using SOAP.
Figure 9: "CallerService" Web Service
- Create deploy.xml.
="1.0"="UTF-8"
<deploy xmlns="http://ode.fivesight.com/schemas/2006/06/27/dd"
xmlns:pns="http://MyTest.com/Test"
xmlns:wns="http://example.ws">
<process name="pns:Caller">
<active>true</active>
<provide partnerLink="client">
<service name="pns:CallerService" port="CallerPort"/>
</provide>
<invoke partnerLink="DSLink">
<service name="wns:DoSomethingService" port="DoSomething"/>
</invoke>
<cleanup on="always" />
</process>
</deploy>
- Test.
Figure 10: Test Result
Here is the complete list of the files of BPEL project (Caller.bpelex, Caller.wsdl and CallerArtifacts.wsdl are generated).
Figure 11: File List
History
- 27th February, 2009: Initial post