BPEL例子s

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被調用時會使用新的值。
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章