Click here to Skip to main content
Click here to Skip to main content

An Example Of BPEL invoking WebService

, 27 Feb 2009
Rate this:
Please Sign up or sign in to vote.
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.

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

  1. 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 ";
                }
    }
  2. 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
  3. 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

  1. 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.
  2. 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”
  3. Add Assign, Assign1 and Invoke Block in “Caller” process:

    Figure 3: "Caller" BPEL Process
  4. Edit Invoke Block to call “doSomething”.

    Figure 4: "Invoke" Block
  5. 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”
  6. 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”
  7. 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”
  8. 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”
  9. 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
  10. Create deploy.xml.
    <?xml version="1.0" encoding="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>
        <!-- If there is a BPEL process which is also deployed under the same project-->
        <!--<provide partnerLink="DSLink">
          <service name="wns:DoSomethingService" port="DoSomething"/>
        </provide>-->
        <!-- DoSomethingService is an existing/external Web Service -->
         <invoke partnerLink="DSLink">
              <service name="wns:DoSomethingService" port="DoSomething"/>
         </invoke>
         <cleanup on="always" />
      </process>
      </deploy>
  11. 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

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Snail2009

United States United States
No Biography provided

Comments and Discussions

 
Generalerror PinmemberMember 79024486-May-11 5:47 
GeneralI can't find the Caller.wsdl Pinmemberlaimu28-Jul-09 4:17 
GeneralRe: I can't find the Caller.wsdl Pinmemberdongqiu19-Dec-09 20:21 
GeneralRe: I can't find the Caller.wsdl Pinmemberdeenaaaaaaaaaa13-Mar-12 23:06 
me too D'Oh! | :doh:

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 27 Feb 2009
Article Copyright 2009 by Snail2009
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid