-
1. Re: REST API - Obtaining the list of processes/variables for a process
jaysynerzip Apr 15, 2014 7:00 PM (in response to dragos.snk)1 of 1 people found this helpfulFor the item 1 you can use the below rest api to get the deploymentIds
/rest/deployment
-
2. Re: REST API - Obtaining the list of processes/variables for a process
swiderski.maciej Apr 16, 2014 1:33 AM (in response to dragos.snk)and for the second one please file jira to be added in the next version as I see it as very valuable information, that should be part of the get process definition operation that instead of returning simple process ids, it should provide more information such as process name, version, deployment id, variables (names and types). Such data are already available in UI so should be exposed on remote apis as well
HTH
-
3. Re: REST API - Obtaining the list of processes/variables for a process
jaysynerzip Apr 16, 2014 2:31 AM (in response to dragos.snk)Seems we have already a Jira for this.
[JBPM-4178] REST API Enhancement to retrieve all process definitions - JBoss Issue Tracker
-
4. Re: REST API - Obtaining the list of processes/variables for a process
dragos.snk Apr 16, 2014 1:33 PM (in response to jaysynerzip)Thank you, i missed the /rest/deployment command
Did a test today, the /rest/deployment functions properly, but /runtime/{deploymentId}/execute with GetProcessIDs command fails - added a comment on the Jira issue you mentioned, it seems it was never supported.
-
5. Re: REST API - Obtaining the list of processes/variables for a process
jaysynerzip Apr 16, 2014 2:34 PM (in response to dragos.snk)Great.
Yeah right. if that works then we will have different workaround to get the list of processes by passing the deployment id until the feature of getting the list of processes without deployment id has been implemented.
-
6. Re: REST API - Obtaining the list of processes/variables for a process
jaysynerzip Apr 16, 2014 7:42 PM (in response to dragos.snk)Hi Dragos,
Can you please tell me the steps how you are executing the /runtime/{deploymentId}/execute with GetProcessIDs command and what error you are getting?
-
7. Re: REST API - Obtaining the list of processes/variables for a process
dragos.snk Apr 17, 2014 2:06 AM (in response to jaysynerzip)See sample code below:
public class RestClient {
public static void main(String[] args) throws IOException, JAXBException, XMLStreamException {
String user = "krisv";
String password = "krisv";
GetProcessIdsCommand command = new GetProcessIdsCommand();
JaxbCommandsRequest request = new JaxbCommandsRequest("org.jbpm.example:async-examples:1.0", command);
request.setDeploymentId("org.jbpm.example:async-examples:1.0");
JAXBContext jaxbRequest = JAXBContext.newInstance(JaxbCommandsRequest.class);
Marshaller jaxbMarshaller = jaxbRequest.createMarshaller();
URL url = new URL("http://localhost:8080/jbpm-console/rest/runtime/org.jbpm.example:async-examples:1.0/execute");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
String authString = user + ":" + password;
byte[] authEncBytes = Base64.encodeBase64(authString.getBytes());
String authStringEnc = new String(authEncBytes);
connection.setRequestProperty("Authorization", "Basic " + authStringEnc);
connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.setRequestProperty("Accept", "application/xml");
connection.setRequestProperty("Content-Type", "application/xml");
OutputStream os = connection.getOutputStream();
jaxbMarshaller.marshal(request, os);
os.flush();
os.close();
if (connection.getResponseCode() != 200) {
throw new RuntimeException("Failed : HTTP error code : " + connection.getResponseCode());
}
//get the response from the server
BufferedReader br = new BufferedReader(new InputStreamReader((connection.getInputStream())));
String output;
String xmlOutput = "";
System.out.println("Output from Server .... \n");
while ((output = br.readLine()) != null) {
System.out.println(output);
xmlOutput += output;
}
JAXBContext jaxbContext = JAXBContext.newInstance(JaxbCommandResponse .class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
JaxbCommandResponse instance = (JaxbCommandResponse ) jaxbUnmarshaller.unmarshal(new ByteArrayInputStream(xmlOutput.getBytes()));
connection.disconnect();
}
}
The response received from the jBPM (instead of a serialized JaxbCommandResponse with process ids):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><command-response><deployment-id>org.jbpm.example:async-examples:1.0</deployment-id><exception index="0"><command-name>GetProcessIdsCommand</command-name><message>IllegalStateException thrown with message 'String should be handled but is not in JaxbCommandsResponse!'</message></exception></command-response>
A new Jira issue was created for that - [JBPM-4312] REST API - GetProcessIDsCommand does not work - JBoss Issue Tracker
-
8. Re: REST API - Obtaining the list of processes/variables for a process
jaysynerzip Apr 17, 2014 3:39 AM (in response to dragos.snk)HI Dragos,
Thanks for the detailed reply.
But I already figured out how to do this . I am doing in the below way and also I fixed the issue which is causing the exception. Basically the List<String> type was missing in the JaxbCommandResponse.
public class SimpleRestClient
{
public static void main( String[] args ) throws MalformedURLException
{
String deploymentId = "org.jbpm:IntegrationTests:1.0";
URL appUrl = new URL("http://localhost:8080/jbpm-console/");
String user = "admin";
String password = "admin";
RemoteRestRuntimeFactory restSessionFactory = new RemoteRestRuntimeFactory(deploymentId, appUrl, user, password);
RemoteRuntimeEngine engine = restSessionFactory.newRuntimeEngine();
KieSession ksession = engine.getKieSession();
GetProcessIdsCommand getProcessIdsCommand = new GetProcessIdsCommand();
//ksession.execute(getProcessInstancesCommand);
List<String> processIds = ksession.execute(getProcessIdsCommand);
System.out.println("The list of process ids"+processIds);
for(String pid : processIds){
System.out.println("Process Id: "+pid);
}
}
}
This is the output.
The list of process ids[TestPojos5, TestClient, TestPojos4, TestPojos3, TestPojos2, TestTypes, UseInvoice]
Process Id: TestPojos5
Process Id: TestClient
Process Id: TestPojos4
Process Id: TestPojos3
Process Id: TestPojos2
Process Id: TestTypes
Process Id: UseInvoice
Thanks again.
-
9. Re: REST API - Obtaining the list of processes/variables for a process
marccbr Apr 17, 2014 3:42 PM (in response to dragos.snk)I am trying to run http://localhost:8080/jbpm-console/rest/deployment but I am getting the following error;
Could not find MessageBodyWriter for response object of type: java.util.ArrayList of media type: application/xml
Any ideas on what could be causing this? I have the latest jBPM 6.0.1 Final build.
-
10. Re: REST API - Obtaining the list of processes/variables for a process
jaysynerzip Apr 17, 2014 5:29 PM (in response to dragos.snk)Set the Accept header as application/json and it will work.
-
11. Re: REST API - Obtaining the list of processes/variables for a process
marccbr Apr 17, 2014 5:32 PM (in response to jaysynerzip)That did it. Thank you, I was racking my brain trying to figure this out.
-
12. Re: REST API - Obtaining the list of processes/variables for a process
jaysynerzip Apr 17, 2014 10:27 PM (in response to marccbr)Great..
-
13. Re: REST API - Obtaining the list of processes/variables for a process
jmiguel77 Jun 9, 2014 2:23 PM (in response to swiderski.maciej)Hi
I am using bpms 6.0.1.GA; when i invoke this url:
the response is this:
<variables><status>SUCCESS</status><url>/business-central/rest/runtime/com.ec.mutualistapichincha:bpm-listas-negras:1.0.0/process/instance/577/variables</url><variables/></variables>
this information is totally useless; i was expecting the list of variables and the data associated with it;
i am also trying to access the variables data of the process using kie-services-client 6.0.1.Final but it doesn't seem to have any method in the API to return the process variables data.
I need that info in a project i am developing and this is really stopping me
Is there any way to fix this problem ?
-
14. Re: REST API - Obtaining the list of processes/variables for a process
chelsea2015 Sep 21, 2015 2:41 PM (in response to jmiguel77)Hi Jose,
I am in a similar requirement to get response back from JBPM. Could you post If you have any solution implemented for it,
Thanks in advance,