7 Replies Latest reply on Nov 23, 2012 10:35 AM by lauradp

    Passing data to a service task

    teots

      Hi,

      I wrote a simple example which uses a Service Tasks to call a webservice. This works fine. But I have no idea how I can forward the retrieved data to another service task.

       

      This is what I tried to do:

      public void executeWorkItem(WorkItem i, WorkItemManager m) 
      {
           HashMap<String, Object> results = new HashMap<String, Object>();
           results.put("test1", "result1");
           results.put("test2", "result2");
      
           m.completeWorkItem(i.getId(), results);
      }
      

       

      But then I don't know how to access these parameters.

       

      I hope you can help me!

        • 1. Re: Passing data to a service task
          jsvitak

          Hi,

          you have to declare variables at process level and define parameter/result mapping in service task. You can map results of the first service task into process variables and then pass the process variables as an output to the second service task. This can be done in web designer or in Eclipse plugin.

          1 of 1 people found this helpful
          • 2. Re: Passing data to a service task
            teots

            Ok I found where I can set the mapping, but how do I declare variables at process level in the first place?!

            • 3. Re: Passing data to a service task
              jsvitak

              Clicking somewhere on canvas enables you to edit process properties.

              1 of 1 people found this helpful
              • 4. Re: Passing data to a service task
                teots

                Thanks a lot!

                • 5. Re: Passing data to a service task
                  lauradp

                  I was able to set Process variables (see attached picture), and set them in the process main:

                   

                  params.put("Command", workflowName);

                                      params.put("Parameters", null);

                   

                                      // start a new process instance

                                      ksession.startProcess("processpic1.png", params);

                   

                                      System.out.println("Process started ...");

                   

                   

                  but variables are not availabe in taskHandler!

                  • 6. Re: Passing data to a service task
                    salaboy21

                    Did you map the variables as input variables inside the UserTask node??

                    Cheers

                    • 7. Re: Passing data to a service task
                      lauradp

                      Thanks for your answare!

                      Here is the RunAction Mapping:

                       

                      [

                          "name" : "RunAction",

                          "parameters" : [

                            "Command" : new StringDataType(),

                            "Parameters" : new ObjectDataType(),

                          ],

                          "results" : [

                            "ExitValue" : new IntegerDataType(),

                          ],

                          "displayName" : "RunAction",

                        ]