您的位置:首页 > 数据库 > Oracle

Oracle-BPM(七)

2015-07-11 18:13 525 查看
代码下载: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();
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: