0

I created the bpmn project and deployed it to the kieserver,how can I use the rest api of kieserver to call and obtain output variables ?

I have defined process variable in bpmn, but after calling and executing bpmn, I cannot get the process variable in the returned results.

The following are the request message and response message I called

Please help to see if there is a problem with the calling method or parameters

Url: http://127.0.0.1:8080/kie-server/services/rest/server/containers/instances/YgdPostLoanFinalResultDemo_1.0.0-SNAPSHOT

Request:
{
  "commands":[
    {
      "set-global" : {
        "identifier" : "output",
        "object" : {
          "com.ygdpostloan.OutputVariable" : {
            "finalDecisionFlag" : "xxx",
            "targetBehaviorStatus" : null
          }
        },
        "out-identifier" : "output"
      }
    },
    {
      "start-process" : {
        "processId" : "YgdPostLoanFinalResultProcess",
        "data" : null,
        "agendaFilter" : null,
        "parameter" : [
          {
            "value" : {
              "com.ygdpostloan.InputVariable":{
                "sysCode" : "jyd",
                "flagBQS" : null,
                "flagRH" : null,
                "flagXDXWJT" : null,
                "resultBQS" : null,
                "resultRH" : null,
                "resultXDXWJT" : 3
              }
            },
            "key" : "input"
          } 
        ],
        "out-identifier" : "input"
      }
    }
  ]
}

Response:
{
  "type" : "SUCCESS",
  "msg" : "Container YgdPostLoanFinalResultDemo_1.0.0-SNAPSHOT successfully called.",
  "result" : {
    "execution-results" : {
      "results" : [ {
        "value" : {"com.ygdpostloan.OutputVariable":{
  "finalDecisionFlag" : "xxx",
  "targetBehaviorStatus" : null
}},
        "key" : "output"
      }, {
        "value" : 13,
        "key" : "input"
      } ],
      "facts" : [ ]
    }
  }
}

I receive result data through global variable , but I'm not sure whether this method is reasonable. I want to try to receive results through process variable

Variables alse cannot be obtained through the kie server client api

public static void main(String[] args) {
        KieServices kieServices = KieServices.Factory.get();

        CredentialsProvider credentialsProvider = new EnteredCredentialsProvider("kieserver", "kieserver");

        KieServicesConfiguration kieServicesConfig = KieServicesFactory.newRestConfiguration("http://127.0.0.18080/kie-server/services/rest/server", credentialsProvider);

        // Set the Marshaling Format to JSON. Other options are JAXB and XSTREAM
        kieServicesConfig.setMarshallingFormat(MarshallingFormat.JSON);

        KieServicesClient kieServicesClient = KieServicesFactory.newKieServicesClient(kieServicesConfig);

        QueryServicesClient queryServicesClient = kieServicesClient.getServicesClient(QueryServicesClient.class);
        List<ProcessDefinition> processes = queryServicesClient.findProcesses(0, 10);
        System.out.println(processes);

        // Retrieve the RuleServices Client.
        ProcessServicesClient processServicesClient = kieServicesClient.getServicesClient(ProcessServicesClient.class);
        ProcessDefinition processDefinition = processServicesClient.getProcessDefinition("YgdPostLoanFinalResultDemo_1.0.0-SNAPSHOT", "YgdPostLoanFinalResultProcess");
        System.out.println(processDefinition);

        Map<String, Object> inputMap = new HashMap<>();
        Map<String, Object> intParamMap = new HashMap<>();
        intParamMap.put("resultXDXWJT", 3);
        intParamMap.put("sysCode", "111");
        Map<String, Object> processParamMap = new HashMap<>();
        InputVariable inputVariable = new InputVariable();
        inputVariable.setResultXDXWJT(3);
        inputVariable.setSysCode("111");
        inputMap.put("com.ygdpostloan.InputVariable", inputVariable);
        processParamMap.put("input", inputMap);

        Long instanceId = processServicesClient.startProcess("YgdPostLoanFinalResultDemo_1.0.0-SNAPSHOT", "YgdPostLoanFinalResultProcess", processParamMap);
        System.out.println(instanceId);

        ProcessInstance processInstance1 = processServicesClient.getProcessInstance("YgdPostLoanFinalResultDemo_1.0.0-SNAPSHOT", instanceId, true);
        System.out.println(processInstance1);

        //Map<String, Object> processInstanceVariables = processServicesClient.getProcessInstanceVariables("YgdPostLoanFinalResultDemo_1.0.0-SNAPSHOT", instanceId);
        //System.out.println(processInstanceVariables);

        List<NodeInstance> completedNodeInstances = queryServicesClient.findCompletedNodeInstances(instanceId, 0, 10);
        System.out.println(completedNodeInstances);

        //Map<String, Object> processInstanceVariables = processServicesClient.getProcessInstanceVariables("YgdPostLoanFinalResultDemo_1.0.0-SNAPSHOT", instanceId);
        ProcessInstance processInstance = queryServicesClient.findProcessInstanceById(instanceId);
        System.out.println(processInstance);
        Map<String, Object> variables = processInstance.getVariables();
        System.out.println(variables);  // return null
    }

0 Answers0