Follow these steps:
- First, download and install "HelloWorld" Web Service into your servlet container. This simple service has 2 operations:
- sum: returns the result of adding two numbers. This is the operation we will use.
- example: concatenates your input with "External WebService".
- sum: returns the result of adding two numbers. This is the operation we will use.
- Before calling this WS check if the web service is working fine. Test the "sum" operation.
- Open your Eclipse and create a new BPEL project. Name it as "HelloCaller".
- Create a new BPEL process file with the following data:
- BPEL Process name: helloCaller
- Namespace: http://mydomain.org/bpel/helloCaller
- Template: Synchronous BPEL process
- Add the HelloWorld WSDL file into the process. Be sure your file is visible to your project.
- Add a Partner Link and named it as "helloLnk".
- Open the details of "helloLnk" and click on "Browse" button. Then a dialog will appear, at the bottom click over the "Add WSDL" button. Select the HelloWorld WSDL file.
- Select the port named as "HelloWorldServicePortType"and click "OK" button; a new dialog will appear.
- Define the name of your Partner Link Type as "helloPLType" and click "Next" button.
- Type a Role Name as "helloProvider" and click "Finish" button.
- Define the name of your Partner Link Type as "helloPLType" and click "Next" button.
- Bellow the "Partner Role" section select "helloProvider".
- Open the BPEL process (helloCaller.bpel) with the BPEL designer and add the following activities and name them as suggested:
- Assign: InitializeVars
- Invoke: SumNumbers
- Assign: SetResult
You should see your diagram as the following: - Open the properties of "SumNumbers" and select the "sum" operation from the "HelloWorldPortType".
- Open the properties of "InitializeVars" activity and add a copy step.
- From: Fixed Value
- To: Variable
- Select helloLnkRequest the "and then "parameters"
- Add a new copy step to "InitializeVar" with the following data:
- And add the last copy step to the "InitializeVars"
- Now, select the "SetResult" and add 2 steps. In the first one initialize the response:
- From: Fixed Value
<tns:helloCallerResponse xmlns:tns="http://mydomain.org/bpel/helloCaller">
<tns:result/>
</tns:helloCallerResponse> - To: Variable
- Select output the and then "payload"
- From: Fixed Value
- Finally, copy the result from the "HelloWorld" service to the output of your BPEL process.
- You need to define the service and the location of it.
- Define the deployment descriptor. Remember that for every partner link used with a <receive> activity must be matched with a <provide> element, and every partnerLink used in an <invoke> activity must be matched with an <invoke> element in deploy.xml. For example, for this process the following code is used:
<active>true</active>
<provide partnerLink="client">
<service name="pns:helloCallerService" port="helloCallerPort" />
</provide>
<!-- Hello World Web Service -->
<invoke partnerLink="helloLnk">
<service name="wns:HelloWorldService" port="HelloWorldServiceHttpPort" />
</invoke>
</process>
- Now, deploy your helloCaller service and test it. Download the example from here.
Software required to run the example:
- Eclipse
- BPEL designer for Eclipse - http://www.eclipse.org/bpel/
- Apache ODE 1.3.2
References
1 comment:
thanks for the post! this one is really helpful.
Post a Comment