Activiti webService task演示实例


一、webservice的服务端简单实现

@WebService
public interface Calculator {
	@WebMethod
	@WebResult(name = "num3")
	public int plus(@WebParam(name = "num1") int num1,
			@WebParam(name = "num2") int num2);
}


@WebService(endpointInterface = "com.first.service.Calculator",
			serviceName = "calculator")
public class CalculatorImpl implements Calculator{

	@Override
	public int plus(int num1, int num2) {
		return num1+num2;
	}

}

public static void main(String[] args) {
		Calculator calculator;
		Server server;
		calculator = new CalculatorImpl();
	        JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
	        svrFactory.setServiceClass(Calculator.class);
	        svrFactory.setAddress("http://localhost:63081/calculator");
	        svrFactory.setServiceBean(calculator);
	        svrFactory.getInInterceptors().add(new LoggingInInterceptor());
	        svrFactory.getOutInterceptors().add(new LoggingOutInterceptor());
	        server = svrFactory.create();
	        server.start();
}


java实现一个简单的webservice服务端,并且为调用方法的传入传出参数指定名称,方便activiti中引用

 


二、activiti 流程定义文件



             
 			 
			 
  
    
    
    
    

                  
      
        input1
        num1
      
      
        input2
        num2
      
      
      	num3
      	output3
      
    
    
    
    
    
  
  
  
  
  
  
  
  
  
  
  
  
    
    
      tns:plusRequestMessage
      tns:plusResponseMessage
    
  
  
  
  
  
  
  
  
  
    
      
        
      
      
        
      
      
        
      
      
        
      
      
        
        
      
      
        
        
      
      
        
        
      
    
  

 

流程执行代码

                  ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("acitiviti.cfg.xml");
		RepositoryService repositoryService=(RepositoryService) applicationContext.getBean("repositoryService");
		RuntimeService runtimeService  = (RuntimeService) applicationContext.getBean("runtimeService");
		IdentityService identityService=(IdentityService) applicationContext.getBean("identityService");
		repositoryService.createDeployment().addClasspathResource("calculator.bpmn20.xml").deploy();
		
		Map map=new HashMap();
		map.put("input1", 2); 
		map.put("input2", 3);
		ProcessInstance pi=runtimeService.startProcessInstanceByKey("process1", map);
		System.out.println(pi.getId());
		
		
		TaskService taskService = (TaskService) applicationContext.getBean("taskService");
		taskService.claim("12", "yuyong");
		taskService.complete("12");
		int output = (Integer) runtimeService.getVariable("5", "output3");
		System.out.println(output);


 

你可能感兴趣的:(Activiti webService task演示实例)