2 Replies Latest reply on Jul 30, 2014 11:39 AM by mysteryblinky

    How to pass an object into a startProcess using REST API or Java Remote API?

    mysteryblinky

      From what i can tell by googling, there's no way to do this. But before I give up, I wanted to ask the forum.

       

      I am able to use the REST API as well as the Java Remote API to start a process and pass variables into it. These variables can be Strings or Longs or etc.

       

      However, I have a process that I need to pass a populated "Person" object into. I created this object definition in the "Data Modeler" in the workbench and it's for testing, so it's very simple: it has only the fields "name" and "age".

       

      I have tried a variety of approaches, but the most intuitively appealing one was importing the "Person" class I created in the Data Modeler, instantiating it, and putting that in the map that i pass into startProcess() with the key being the name of the variable that my process expects. When i looked at the results of this in the workbench (the "Process Variables" view of the instance), the value was null.

       

      How do I use either API to pass in a custom object?

       

      I am a JBPM beginner, so i'm just climbing up the learning curve. FYI, it's not a problem with my process -- I have tested this process via the workbench as well as both REST and Remote Java APIs and the process works fine.

       

      Thanks for any help!

        • 1. Re: How to pass an object into a startProcess using REST API or Java Remote API?
          swiderski.maciej

          recommended approach is to use Java Remote API in case custom objects are required. In your case you would need to:

          • model class in data modeler
          • define it as variable in your proces
          • build and deploy the project
          • create client project in your IDE (preferable maven project)
          • define dependency to the project created in kie-workbench in your client project
          • create instance of that class in your client project
          • use that instances as map element for start process

          this is completely supported use case and has been validated on latest 6.1.0.CR2 available

           

          HTH

          • 2. Re: How to pass an object into a startProcess using REST API or Java Remote API?
            mysteryblinky

            thanks for your response. I believe that I understand (and have done) all the steps except for this one:

             

            > define dependency to the project created in kie-workbench in your client project

             

            How do i do that? Also can you explain why this is needed? I'm passing the object into a startProcess() call in my client code. I suppose I need to do it so that the engine knows what class to use to deserialize my object?

             

            And I have one question about this point:

             

            > use that instances as map element for start process

             

            My question here is what do i use as the "key" in the Map? I put the instance of the class as the value in the Map, but what should i use as the key? I've tried using a) the name of the process variable i created; b) the name of the class itself (not the fully-qualified name, however -- didn't try that).

             

            thanks!