Re: Invoke a HP OO 10.01 Flow using a script (163 Views)
Reply
Occasional Visitor
trsandeep
Posts: 2
Registered: ‎01-30-2014
Message 1 of 2 (186 Views)

Invoke a HP OO 10.01 Flow using a script

Hi all,

 

We have flows that was initially written for HP OO 7.10 and was in use till now, it was being invoked using a external Perl and Java on demand. The flow url and flow input values was passed the as the http get method.

 

We have recently upgraded the set-up to 10.01 HP OO server and the flows are successfully upgraded and imported into the new central server. But our previous script that used to invoke these flows by using the url and passing the input values is no more able to invoke the flows on HP OO 10.01.

 

How do we accomplish this on the new HP OO 10.01 server ?

 

My flow (for testing) is a simple one which takes in two input parameters - min and max.

 

When I login to central it shows the following:

 

TestFlow
    ID: 6bbd6707-af79-4b9d-b1df-d2cb5062e6f9
    Path: Library/Sample/TestFlow.xml
   Content Pack: Sample
   Version: 1.0.1
    Run Link: https://testdevserver.com:8443/oo/trigger.html#6bbd6707-af79-4b9d-b1df-d2cb5062e6f9

 

By clicking on the Run Link it takes to a page where I have to enter min and max value and then submit. But what I need is a url where I can directly pass on the values for min and max

 

I did try :: https://testdevserver.com:8443/oo/trigger.html#6bbd6707-af79-4b9d-b1df-d2cb5062e6f9?min=10&max=20

 

but it did not work.

 

I also tried https://testdevserver.com:8443/oo/Library/Sample/TestFlow?min=10&max=20

 

but neither did that work. Any help regarding the same would be greatly appreciated.

Please use plain text.
Occasional Visitor
trsandeep
Posts: 2
Registered: ‎01-30-2014
Message 2 of 2 (163 Views)

Re: Invoke a HP OO 10.01 Flow using a script

Finally after doing a bit of googling i found the way to do it. 

 

Here is a sample Java code, just incase some one requires it. I am invoking a test flow with two inputs min and max.

I have taken this code from http://stackoverflow.com/  and edited it to my need so that it can invoke a HP OO flow.

 

To run this program you will need apache http jars and json jars. A simple search regarding the import statments will tell you which jars you need to download. I used httpclient-4.3.2.jar, httpcore-4.3.1.jar and json-simple-1.1.jar

 

 

 

package testCode;

 

import java.io.IOException;

import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.json.simple.JSONObject;

 


public class FlowInvokeUUID {

 

   public static void main(String[] args) throws IOException {

 

       JSONObject json = new JSONObject();
       json.put("uuid", "6bbd6707-af79-4b9d-b1df-d2cb5062e6f9");
       json.put("runName", "Test-Run");
       json.put("logLevel", "DEBUG");

      JSONObject inputs = new JSONObject();
      inputs.put("min", "10");
      inputs.put("max", "20");

 

      json.put("inputs", inputs);

      CloseableHttpClient httpClient = HttpClientBuilder.create().build();

 

       try {
             HttpPost request = new HttpPost("http://localhost:8181/oo/rest/executions/");
             StringEntity params = new StringEntity(json.toString());
             request.addHeader("content-type", "application/json");
             request.setEntity(params);
             HttpResponse response = httpClient.execute(request);
             System.out.println(response);
       } catch (Exception ex) {
            System.out.println(ex.getMessage());
       } finally {
            httpClient.close();
       }

   }

}

Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation