代碼下載下傳:git
7、bpm api之以taskNumber或taskId查詢
語言:java
package test01;
import com.taskQuery.services.TaskQueryService;
import com.taskQuery.services.TaskQueryService_Service;
import com.taskQuery.services.WorkflowErrorMessage;
import java.math.BigInteger;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import oracle.bpel.services.workflow.common.model.CredentialType;
import oracle.bpel.services.workflow.common.model.WorkflowContextType;
import oracle.bpel.services.workflow.query.model.TaskDetailsByNumberRequestType;
import oracle.bpel.services.workflow.task.model.Task;
import org.w3c.dom.Node;
public class test1 {
public test1() {
super();
}
//結合XML結構分析
//1、以taskNumber來查詢
/* <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"xmlns:tas="http://xmlns.oracle.com/bpel/workflow/taskQueryService"xmlns:com="http://xmlns.oracle.com/bpel/workflow/common">
<soapenv:Header/>
<soapenv:Body>
<tas:taskDetailsByNumberRequest>
<com:workflowContext>
<com:credential>
<com:login>weblogic</com:login>
<com:password>weblogic1</com:password>
</com:credential>
</com:workflowContext>
<tas:taskNumber>200000</tas:taskNumber>
</tas:taskDetailsByNumberRequest>
</soapenv:Body>
</soapenv:Envelope>
//2、以taskId來查詢
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tas="http://xmlns.oracle.com/bpel/workflow/taskQueryService" xmlns:com="http://xmlns.oracle.com/bpel/workflow/common">
<soapenv:Header/>
<soapenv:Body>
<tas:taskDetailsByIdRequest>
<com:workflowContext>
<com:credential>
<com:login>weblogic</com:login>
<com:password>weblogic1</com:password>
</com:credential>
</com:workflowContext>
<tas:taskId>3fa4e9f7-5719-4efa-8215-ad2b47fcbace</tas:taskId>
</tas:taskDetailsByIdRequest>
</soapenv:Body>
</soapenv:Envelope>
*/
/*
* function testAccess
* 作用:human Task 登陸驗證
* 參數:無
* return 無
*
*/
public void testAccess(){
try{
//1、建立【啟動】一個Task查詢服務對象。
TaskQueryService_Service taskQueryService_Service = new TaskQueryService_Service();
//2、獲得一個Task查詢服務執行個體。
TaskQueryService taskQueryService = taskQueryService_Service.getTaskQueryServicePort();
//3、擷取憑證【通過憑證登陸,才能通過驗證】
//建立一個CredentialType,存儲各種憑證
CredentialType credentialType = new CredentialType();
credentialType.setLogin("weblogic");
credentialType.setPassword("11111111");
//4、通過憑證,登陸驗證。【在有操作者的情況之下,human task才能成功被操作】
System.out.println("Authenticating...");
WorkflowContextType workflowContextType = taskQueryService.authenticate(credentialType);
System.out.println("Authenticated to TaskQueryService");
//5、成功登陸之後,通過task number、taskid等查詢整個task【這裡使用task number】
//建立一個TaskDetailsByNumberRequestType,存儲查詢task時需要的task number
TaskDetailsByNumberRequestType taskDetailsRequest = new TaskDetailsByNumberRequestType();
taskDetailsRequest.setTaskNumber(new BigInteger("200029"));
taskDetailsRequest.setWorkflowContext(workflowContextType);
//6、查詢task
Task task = taskQueryService.getTaskDetailsByNumber(taskDetailsRequest);
System.out.println("Task:" + task.getSystemAttributes().getTaskId());
}catch(WorkflowErrorMessage e){
Logger.getLogger(test1.class.getName()).log(Level.SEVERE, null, e);
}
}
public static void main(String [] args){
test1 test = new test1();
test.testAccess();
}
}