现在的位置: 首页 > 综合 > 正文

BPEL例子s

2013年09月06日 ⁄ 综合 ⁄ 共 7616字 ⁄ 字号 评论关闭

BPEL Samples
 
BPEL例子
 
As of this writing, there is one sample BPEL process that comes with the ActiveBPEL™ engine. This document comes from the README.txt file included with the sample code.
 
就标题所写,这是一个使用ActiveBPEL™引擎的BPEL流程样例。本文来自在例子代码中的README.txt
 
The samples/loan_approval directory contains the files that make up the example loan approval BPEL process, two auxiliary Web services upon which it depends, two command-line test clients, and a BPEL process client JSP page. The loan approval process is the same as the one used in the BPEL specification Business Process Execution Language for Web Services Version 1.1.
 
samples/load_approval目录下包括拼凑借货BPEL流程例子的文件,两个依赖的辅助性Web service,两个命令行测试客户端,和一个BPEL客气端JSP网页。这个借货流程和BPEL规范中的Business Process Execution Language for Web Services Version 1.1是一样的。
 
The values sent to the BPEL process and returned by the assessor and approver are read from a configuration file. See The Config File below.
 
把值传送到BPEL流程并返回从配置文件中的assessor和approver,请看下面的配置文件。
 
Dependencies
 
依赖
 
You must have a working ActiveBPEL engine. See Installing and Configuring the ActiveBPEL Engine.
 
你必须有一个正在运行的ActiveBPEL引擎。查看《ActiveBPEL引擎的安装与配置》。
 
You need Ant in order to run the targets in the build.xml file. You could do everything manually, but the rest of this document assumes you have Ant.
 
你需用到Ant来运行build.xml文件中的target。一切你都可以手动来做,但本文假定你使用Ant
 
The environment variable CATALINA_HOME must be defined so the Ant script knows where to deploy everything.
 
必须正确定义环境变量CATALINA_HOME,以便Ant脚本知道要分发到哪。
 
Setup
 
配置
 
If your ActiveBPEL engine installation is not running on "localhost:8080", change that string in the three files containing it:
 
如果你的ActiveBPEL引擎不是运行在”localhost:8080”,修改下面三个文件中对应的字串:
 
  • bpel_example_config.xml
  •  
  • bpel_process/wsdl/loanapprover.wsdl
  •  
  • bpel_process/wsdl/loanassessor.wsdl
  •  
Deploying the BPEL Process
 
配置BPEL流程
 
From the command line, navigate to the directory <installdir>/activebpel-version/ samples/loan_approval (where "version" is a version number like 0.9.5. All subsequent commands will be run from this directory.
 
在命令行下,转到<installdir>/activebpel-version/ samples/loan_approval目录。所有后来的命令都会在这目录运行。
 
To deploy the BPEL process, type
 
要分配置BPEL流程,输入
ant deploy
If the ActiveBPEL engine is running, soon after you deploy your BPEL process the ActiveBPEL engine will notice the .bpr file and read it. Your BPEL process is ready to use.
 
如果ActiveBPEL在运行,配置BPEL流程后不久,ActiveBPEL引擎会注意到这个bpr文件,并读取它。BPEL流程准备好使用了。
 
See Starting the ActiveBPEL Engine for instructions on starting and stopping the engine.
 
参阅《开启ActiveBPEL Engine》来了解关于开启与关闭引擎。
 
The deploy target calls three other targets: deploy-bpel, deploy-ws, and deploy-jsp. deploy-bpel creates and installs a .bpr archive file that contains the BPEL process information. deploy-ws creates and installs a .bpr file that contains the Web services. deploy-jsp creates and installs a .wsr file that contains the JSP page and supporting classes.
 
deploy这个target调用另外三个target:deploy-bpeldeploy-wsdeploy-jspdeploy-bpel建立与安装一个包括BPEL流程信息的bpr文件。deploy-ws新建与安装包含Web serviceBPR文件。deploy-jsp新建与安装一个包含JSP网页和所需类的wsr文件。
 
The Web services don't need to be in a .bpr file to be deployed, but doing so lets the ActiveBPEL engine find the file and hand the Web services over to Axis (a SOAP implementation). Using a .bpr file is only a convenience that simplifies deployment. The Web services are independent of the ActiveBPEL engine.
 
这个Web service并不一定要配置到BPR文件中,但这样可让ActiveBPEL引擎找到这文件来,并把这个Web Service交给Axis(一个SOAP实现)来处理。使用BPR文件只是为了简化部署(步骤)。Web service是独立于ActiveBPEL引擎的。
 
Testing the Web Services
 
测试Web service
 
There is a simple command line client that tests the "assessor" and "approver" Web services. These services are used by the BPEL loan approval process. The test client calls each Web service and compares the returned result with the expected value found in the config file. To run the test client, type
 
这里有一些测试“assessor”和“approverWeb service的命令。这些服务被BPEL借货流程所使用。测试客户端调节器用每个Web service和比较返回值与配置文件中预设的值。运行测试客户端,输入:
 
 
ant ws-test-client
(The Web services themselves are deployed by the target deploy-ws as discussed above. However, the target ws-test-client does NOT depend upon the deploy-ws target. Why not? Because things happens too fast: if you deploy the Web services then immediately use the client the server may not have time to notice and (re)initialize the Web services. You must use either the deploy-ws or deploy targets before running the test client.)
 
Web services他们上面说那样由deploy-ws这个target配置。然而,ws-test-client并不依赖于deploy-ws。为什么呢,因为事情发生得太快:如果你配置Web service就立即使用客户端端,服务端可能没有时间注意到或重初始化Web service。你必须在运行ws-test-client前,使用deploy-wsdeoloy target
 
The output is similar to JUnit output; if all is well, you will see
 
输出有点象Junit;如果一切正常,你会看到:
 
 
 ..
 
OK 2 tests; 0 errors
If one fails you will see something like
 
如果有错误,你会看到象下面的东西:
 
 
E.
 
assessor expected result "low" does not match returned result "foo"
 
ERROR 2 tests; 1 error
Web Services and the ActiveBPEL Engine
 
Web ServiceActiveBPEL引擎
 
The Web services are deployed inside a .bpr file, the archive format used for deploying BPEL processes. This is not necessary; it is only a convenience. The ActiveBPEL engine will "notice" the .bpr file and hand our Web services to the Axis SOAP implementation. The engine does not "know" about the Web services directory and does not use any shortcuts to call the Web services.
 
Web Service被分发到一个BPR文件(分发BPEL流程的存档格式)中。这不是必须的;这只是为了文便。ActiveBPEL引擎会“注意”到这个BPR文件,并把Web service交给Axis SOAP执行。引擎并不“知道”Web service的路径也不使用任何shortcut来调用Web service
 
Running the BPEL Process Client
 
运行BPEL流程客户端
 
To run a command-line client that calls the BPEL process Web service, type
 
运行命令行客户端来调用BPEL流程Web service,输入:
ant client
The client compares the value returned by the BPEL process with the config file value /rundata/bpel-expected-response and prints either an OK or an ERROR message.
 
客户端比较BPEL流程的返回值和配置文件的valuerundatabepl-expected-respones并打印是OK还是ERROR消息。
 
As discussed above in Testing the Web Services, you must deploy everything before using this client.
 
就如上面Testing the Web Services所说,你必须在使用这client前配置好所有东西。
 
Using the BPEL Process JSP Client Page
 
使用BPEL流程JSP客户端页面
 
Instead of running the command line clients, you can use the JSP page at http://localhost:8080/bpel_example_client_page/index.jsp. (Again, if your Tomcat installation is not running at localhost:8080, modify the URL accordingly.)
 
你可以运行命令行客户端不同,你可以使用http://localhost:8080/bpel_example_client_page/index.jsp 这个页面(重复,如果Tomcat没有运行于localhost:8080,修改相应的URL)。
 
The page displays many of the values from the config file and lets you edit them. Clicking the "Apply for a Loan" button saves the values you entered to the deployed copy of the config file, sends the loan application request to the BPEL process, and displays the response.
 
这页面显示很多配置文件中的值,并可以编辑。点击“Apply for a Loan”按钮,保存你输入的值到已分发的配置文件副本,传送借应用需求到BPEL流程,并显示响应(信息)。
 
The Config File
 
配置文件
 
The file bpel_example_config.xml contains values used by the test client, the two auxiliary Web services, and the Web services test client.
 
bpel_example_config.xmltest客户端用到的值,两个辅助的Web serviceWeb service的客户端。
 
To deploy the config file manually, type
 
手动分发配置文件,输入:
ant deploy-config
The Ant targets that compile the clients and deploy the Web services all make sure the config file is deployed.
 
Ant target编译客户端并分发已在配置的Web service
 
BPEL process expected response
 
BPEL流程预定回应
 
In order to properly set the value /rundata/bpel-expected-response, you have to understand the example loan approval BPEL process. Here it is, in pseudo-code:
 
为了合理设置value /rundata/bpel-expected-response,你必须理解借货BPEL流程例子,这是“假冒”的代码。
 
 
if (amount < 10000) {
 
    if (assessor returns "low")
 
        return "yes"
 
    else
 
        return approver response
 
}
 
else
 
    return approver response
If the assessor Web service encounters an error, it returns "high". If the approver encounters an error, it returns "no".
 
如果assessor Web service遇到错误,则返回“high”。如果approver遇到错误,返回“no”。
 
Config file changes
 
配置文件的变更
 
Instances of RuntimeParams are responsible for reading the config file. They do so in the constructor. This means that each time a RuntimeParams object is created the config file is re-parsed, allowing the config file changes to be recognized immediately. For example, Web services create a RuntimeParams object each time they are called. That means you can change the config file and deploy it and the next time a Web service is called it will use the new values.
 
 
 
RuntimeParams实例在构建的时候负责读取配置文件。这意味着每一次RuntimeParams对象被建立时配置文件会初再度分析,让配置文件的变更立即被验证。如,Web service在每次被调用时建立RuntimeParams对象。也就是说,你可以改变并分发配置文件,且在下一次Web Service被调用时会使用新的值。
 

抱歉!评论已关闭.