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

An Example Of BPEL invoking WebService

By , 27 Feb 2009
 

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
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralerrormemberMember 79024486 May '11 - 5:47 
Very good tutorial!
I tried to do the same (with my service, different from yours) but when I test the BPEL process with the "web service explorer", there was this error:
 
Request:
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:q0="http://workspace" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <soapenv:Body>
- <q0:GestioneMagazzinoRequest>
  <q0:input>1</q0:input> 
  </q0:GestioneMagazzinoRequest>
  </soapenv:Body>
  </soapenv:Envelope>
 
Response:
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
- <soapenv:Body>
- <soapenv:Fault xmlns:java="java:package org.apache.ode.bpel.iapi">
  <faultcode>java:org.apache.ode.bpel.iapi.BpelEngineException</faultcode> 
  <faultstring>Error in deployment descriptor for process {http://magazzino}GestioneMagazzino-4; reference to unknown partner link MonitorPL</faultstring> 
- <detail>
  <Exception>org.apache.ode.axis2.OdeFault: Error in deployment descriptor for process {http://magazzino}GestioneMagazzino-4; reference to unknown partner link MonitorPL at org.apache.ode.axis2.ODEService.onAxisMessageExchange(ODEService.java:146) at org.apache.ode.axis2.hooks.ODEMessageReceiver.invokeBusinessLogic(ODEMessageReceiver.java:69) at org.apache.ode.axis2.hooks.ODEMessageReceiver.invokeBusinessLogic(ODEMessageReceiver.java:52) at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:96) at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:145) at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275) at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:120) at javax.servlet.http.HttpServlet.service(HttpServlet.java:641) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:394) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) Caused by: org.apache.ode.bpel.iapi.BpelEngineException: Error in deployment descriptor for process {http://magazzino}GestioneMagazzino-4; reference to unknown partner link MonitorPL at org.apache.ode.bpel.engine.BpelProcess.setRoles(BpelProcess.java:500) at org.apache.ode.bpel.engine.BpelProcess.access$1300(BpelProcess.java:89) at org.apache.ode.bpel.engine.BpelProcess$HydrationLatch.doHydrate(BpelProcess.java:884) at org.apache.ode.bpel.engine.BpelProcess$HydrationLatch.access$100(BpelProcess.java:800) at org.apache.ode.bpel.engine.BpelProcess$HydrationLatch$2.run(BpelProcess.java:810) at org.apache.ode.bpel.engine.NStateLatch.latch(NStateLatch.java:89) at org.apache.ode.bpel.engine.BpelProcess.getEndpointToMyRoleMap(BpelProcess.java:730) at org.apache.ode.bpel.engine.BpelProcess.initMyRoleMex(BpelProcess.java:310) at org.apache.ode.bpel.engine.BpelEngineImpl.createNewMyRoleMex(BpelEngineImpl.java:187) at org.apache.ode.bpel.engine.BpelEngineImpl.createMessageExchange(BpelEngineImpl.java:157) at org.apache.ode.bpel.engine.BpelEngineImpl.createMessageExchange(BpelEngineImpl.java:210) at org.apache.ode.axis2.ODEService.onAxisMessageExchange(ODEService.java:110) ... 25 more</Exception> 
  </detail>
  </soapenv:Fault>
  </soapenv:Body>
  </soapenv:Envelope>
 
What's wrong in your opinion??
Thanks in advance!
GeneralI can't find the Caller.wsdlmemberlaimu28 Jul '09 - 4:17 
sorry, when I do it follow you, but,the program doesn't generate a Caller.wsdl,I don't know why.
GeneralRe: I can't find the Caller.wsdlmemberdongqiu19 Dec '09 - 20:21 
I have the same problem!
GeneralRe: I can't find the Caller.wsdlmemberdeenaaaaaaaaaa13 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   

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 27 Feb 2009
Article Copyright 2009 by Snail2009
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid