天天看點

建構富網際網路應用程式監控工作流和流程(3)

接口

 使 使用者能夠...

 IDeliveryService

 從 BPEL 流程域上部署的流程中調用執行個體

 IBPELProcessHandle

 浏覽 BPEL 流程域上部署的 BPEL 流程

 IInstanceHandle

 對 活動執行個體執行操作

 ITask

 與 流程域中已經執行個體化的任務互動

 IWorklistService

 搜尋 并完成已經從流程域中執行個體化的任務

  您已經了解了 RIA 和 BPELService 的基本元件,下面将介紹它們如何協同提供豐富的最終使用者體驗。

  運作新帳戶流程

  如前所述,首先向客戶顯示工作流面闆中的輸入螢幕以輸入 SSN。當使用者單擊 Submit 時,将使用 ActionScript 建立一個“新帳戶應用程式”XML 文檔,并通過 Flex 的遠端對象體系結構将其傳遞給 BPELService 伺服器端 Java 類。(這使 Flex 能夠直接與 BPELService 等 Java 對象進行通信。)Java 元件使用 IDeliveryService 接口的執行個體初始化 BPEL 流程。随後,如下所示,initiateProcess Java 方法将新建立的業務流程執行個體的執行個體引用 ID 傳回給 Flex 用戶端。随後的操作中使用此引用 ID 将相應的業務流程執行個體作為目标。

/**

* This function initiates an instance of a BPEL PM process based on the

* process name.The function sets the function id and the reference id for

* future use.

*

* @param xmlRequest

*            is the initiating request message for the process

* @param strBusinessProcess

*            the business process name

* @return the initiating response message for the process

*/

public String initiateProcess(Document xmlRequest, String strBusinessProcess) {

System.out.println("Initiate" + strBusinessProcess);

/*

* This interface allows users to invoke instances from processes

* deployed on a BPEL process domain.

IDeliveryService deliveryService = getDeliveryService();

* Construct the normalized message and send to Oracle BPEL process

* manager

NormalizedMessage nm = new NormalizedMessage();

nm.addPart(PAYLOAD, xmlRequest.getDocumentElement());

NormalizedMessage responseNm = null;

try {

responseNm = deliveryService.request(strBusinessProcess, PROCESS,

nm);

} catch (Exception e){

e.printStackTrace();

throw new RuntimeException("Could not initialize process.");

}

Map payload = responseNm.getPayload();

Document xmlResponse = getXMLDoc(XMLHelper

.elementToString((Element) payload.get(PAYLOAD)));

* Sets the Instance reference ID for interagating active BPEL

* instances.

setInstanceReferenceId(strBusinessProcess, xmlResponse);

return XMLHelper.elementToString(xmlResponse.getDocumentElement());