Creating a Web Service mix using BPEL

Source: Internet
Author: User
Tags soap wsdl

Http://www.cnblogs.com/ahhuiyang/archive/2012/12/18/2824131.html

For simplicity, the Web service composition of this example calls only one Web services API.
The environment for this article is: installation of Eclipse Juno Release + JRE 1.7 + Tomcat 7.0.29 + BPEL + ode,eclipse, JRE environment variable configuration and Tomcat configuration This article does not speak. BPEL does not seem to run on myeclipse, I am not successful in the MYECLIPSE environment and may be related to port contention.

On-line BPEL primer Most of the articles have problems, or older but the new version has changed, or some of them in the implementation of the problems encountered, this article is I spent two days to find out, collation down for forgetting, is the basis of BPEL primer, Daniel will not have to read.

1. Apache Ode Installation and Configuration

Download the Ode War file from http://ode.apache.org/, This example downloads the file Apache-ode-war-1.3.5.zip, unzip the file, find the Ode.war, put it into the Tomcat home directory WebApps directory, and then go to the "Tomcat home directory \ Bin" directory, start the Tomcat server, After successful startup, enter Http://localhost:8080/ode in the browser and if the following page is displayed in the browser, the ODE installation is successful:

2. BPEL Visual Designer Installation

Open Eclipse, click the menu "Help->install New software ..." to pop up the "Install" dialog box, click "Add ..." button, in the popup dialog box, enter "BPEL" in the Name box, Enter http://download.eclipse.org/bpel/site/in the Location box and click the "OK" button when you are done.

Eclipse automatically lists all the components that can be downloaded for installation, as shown in:

Select all three Bpel Commons, Bpel Visual Designer, and Runtime Adapter for Apache ODE 1.3, and then tap Next until the installation is complete.

Click the Eclipse Menu "File->new->other", enter "BPEL" in wizards, if the following three items appear, the BPEL installation is successful:

3. Eclipse Ode Server Configuration

Although you can create a ODE server when you create a BPEL project, you can now configure the ODE server in eclipse to be easier to use later.

The port number that Tomcat uses by default is 8080, so there is a problem with ode using 8080 ports, and when Ode's host server Tomcat uses 8080 ports, Ode does not seem to be able to use the other ports and must use 8080 ports. If both the service API and BPEL are running on the same machine, and both are in the same Tomcat directory, there is a problem when deploying BPEL using ODE. A preliminary analysis, possibly a port number contention, has been tried many times to finally find a solution: Using the Tomcat Deployment service on another machine, deploying the BPEL service mix on this machine, and Tomcat on the other machine and the ODE server on this machine use port 8080.

Web Service Address: Http://192.168.10.179:8080/Fibonacci/FibonacciPort?WSDL

Ode server address: Http://localhost:8080/ode

Description: 192.168.10.179 is not localhost.

Click on the Eclipse menu "Window->preferences->server->runtime environments", click "Add" button, enter the content shown in the popup dialog box, Where the Tomcat directory is a directory on your own machine:

Click "Finish" button to complete the configuration.

4. Create a BPEL service mix

The first step is to create a BPEL project

Click "File->new->other", enter "BPEL" in wizards, select "Bpel Project" in the project type that appears, click "Next", enter the project name "Bpelfibonacci" in the popup dialog box. The functionality of the Web service called by this article, such as the name, is to generate the Fibonacci sequence, and the server chooses "ODE" as shown in:

Then click "Next" and finally click "Finish" and a BPEL project is created.

The second step is to create the BPEL Process

In Eclipse's Package Explorer, right-click "Bpelcontent" Under Bpelfibonacci, select "New->other" in the pop-up menu, and enter "BPEL" in the Wizards text box of the popup dialog box. Then select "BPEL Process File" In the list and click "Next".

Process name Enter "Bpelfibonacci", namespace enter http://bpel.sklse.org, then click "Next" to pop up the following dialog box:

Change template to sync, drop-down list select "Synchronous BPEL Process" and change service address to http://localhost:8080/ode/processes/ Bpelfibonacci, other unchanged, click on the "Next" button, then click the "Finish" button, the system created a process file for us, and automatically opened the Flow editor.

The third step is to add the WSDL file of the service to the project

No matter how you use it, add the WSDL file of the service to the project's Bpelcontent folder, and make sure the address in the WSDL file is available, that is, the WSDL file can be accessed through the browser. In this example, the WSDL file used is fibonacciport.wsdl.

Fourth step, edit process

No matter what the initial process is, drag the "Actions" by dragging the two assign and an invoke to make the flowchart as shown:

Step fourth A, edit invoke, create a partner link

The core of the process is the execution of the service, and the partner link is actually specifying which service the process is bound to, and the bound service will be executed. A service has inputs and outputs.

This process contains only the most basic three parts: input, execution, and output, respectively, corresponding to "Receiveinput and Assigninputtosoaprequest", "Invokefibonacci", and " Replyoutput and Assignoutputtoresult ".

Select "Invokefibonacci" to open the "Properties" tab under Eclipse (if not, click the Eclipse menu "Window->show view->properties"), You can see the interface shown below:

Click "Details", in the right panel click on the "Partner link" text box after the drop-down triangle, select "Create Global Partner link", Open the Creating Link dialog box, first enter the partner link name "BPELFIBONACCIPL" :

Click the "OK" button and select the Web service that is linked to, that is, the Fibonacci services:

Select source and filter conditions for "from Project" and "Show Port Types", select "Fibonaccidelegate" in "Matches", "Fibonaccidelegate" will automatically appear in "Partner Link Type Structure ", here also select" Fibonaccidelegate ", then click" OK "button, enter next, enter the partner link type name:

Enter "Bpelfibonacciplt", the name is arbitrary, then click on the "Next" button, enter the role name "Bpelfibonaccirole", select the following Web service "Fibonaccidelegate", click "Next", The dialog box is not entered in the popup, then click "Finish" to complete the creation of the partner link.

When you're done, choose which action to perform, in this case select "Getfibonacciarray", which is to get the Fibonacci sequence, set the input focus to "operation" as shown, and then double-click on the right "Getfibonacciarray" , input and output variables are automatically generated, which correspond to the inputs and inputs of getfibonacciarray, and the data structures are consistent with those defined in the Fibonacci WSDL.

Fourth step B, assigning inputs and outputs

Fibonacci has two Web service interfaces, we select Getfibonacciarray, whose input is an integer (int) number, greater than or equal to 1, which represents the number of bits before the Fibonacci sequence, and the output is a string type.

The default input type for BPEL project is not an int but a string, so we want to change the input type to int, and you have to change the "bpelfibonacciartifacts.wsdl" file for this type.

In Project Explorer, right-click on "bpelfibonacciartifacts.wsdl" and in the popup menu, select "Open with->wsdl Editor" to open the WSDL editor, as shown in:

Locate input under Bpelfibonacci, click on the right arrow, and in the popup interface, change the input type string to int and click "Save". Because the output is of type string, you do not have to change it. Then, we can assign the input.

Click "Assigninputtosoaprequest", expand its properties page, switch to the "Details" tab, click "New" to create a new input assignment, "from" Select "Input: Bpelfibonaccirequestmessage->payload:bpelfibonaccirequest->input:int ", in" to "select" Bpelfibonacciplrequest: Getfibonacciarray->parameters:getfibonacciarray->arg0:int ", click Save, you will be prompted whether to generate the default input, select Yes, and then click Save, so that the input assignment is completed.

Also for the output, note that the output from the partner link to the output of the process, as shown in:

Attention:

The service address entered when the BPEL process was originally created is Http://localhost:8080/ode/processes/BPELFibonacci, but " BPELFIBONACCIARTIFACTS.WSDL "The address recorded in the last few lines of the file is Http://localhost:8080/BPELFibonacci, open as text" BPELFIBONACCIARTIFACTS.WSDL "and change this address to Http://localhost:8080/ode/processes/BPELFibonacci. The steps are:

In the "Package Explorer" right-click "bpelfibonacciartifacts.wsdl", in the pop-up menu select "Open With->text Editor", in the open editor will be the following lines of code (usually in the last few lines) :

1 <service name= "Bpelfibonacciservice" >2 <port binding= "tns:bpelfibonaccibinding" name= "BPELFibonacciPort" >3 <soap:address location= "Http://localhost:8080/BPELFibonacci"/>4 </port>5 </service>

Switch

1 <service name= "Bpelfibonacciservice" >2 <port binding= "tns:bpelfibonaccibinding" name= "BPELFibonacciPort" >3 <soap:address location= "Http://localhost:8080/ode/processes/BPELFibonacci"/>4 </port>5 </ Service>

5. Deployment

Right click on "Bpelcontent", select "New->other->bpel Deployment descriptor" in the pop-up menu, click "Next", then "Finish", will automatically open the Deploy edit page.

Select "Bpelfibonacciport" in "Associated Port" under "Inbound Interfaces (Services)" and click on the back of the cell to fill in the contents automatically.

In "Outbound Interfaces (invokes)" under "Associated Port" select "Fibonacciport", click on the following cell, the content will be automatically filled in.

Click "Save".

In "Servers" view, the right-click menu select "New->server", in the Popup dialog box select "ODE v1.x Server", then "Next", then "next", in this dialog box "Bpelfibonacci" through "add "Button to the right, click" Finish ".

Start the ODE server.

6. Testing

Right-click "BPELFIBONACCIARTIFACTS.WSDL" in the "Package Explorer" and select "Web Services->test with Web Services Explorer" in the popup menu. This will open the browser and load the Web service, click "Process", enter "6" and expect the result to be "1 1 2 3 5 8", as shown in the following:

For another example, enter 10 and the result is as follows:

Creating a Web Service mix using BPEL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.