-
1. Re: how to find processDefId by rest commands?
badtea Aug 8, 2014 12:10 PM (in response to greenday_ra)There are some "execute calls" listed in the documentation here: Chapter 17. Remote API.
It says that you pass a
JaxbCommandsRequest
object to the call and you get aJaxbCommandResponse
in reply.There is a list of possible commands you can send. One of the commands is GetProcessIdsCommand. I found the code for this command here, and I think it will give you what you want.
However, I do not understand how you actually make the REST call. Are you supposed to pass the JaxbCommandsRequest object as XML in the REST call? I would be interested to hear if you get this to work.
HTH
-
2. Re: how to find processDefId by rest commands?
greenday_ra Aug 8, 2014 5:14 PM (in response to badtea)Hi Travis
Thanks for your reply,
Yes, I know that commands but, I don't call them rest remote commands.
using them needs to add many complexity to project, adding org.kie.api and org.jbpm.services and more classes
and there is no clear way to add them as I know!
my project is not maven based.
I prefer to use POST and GET commands, they are standard way to implement webservice, I think.
I use this function to send rest commands from my code
private String getDataFromService(String urlpath, String method) throws Exception {
HttpClient httpclient = new HttpClient();
httpclient.getParams().setAuthenticationPreemptive(true);
httpclient.getState().setCredentials(
new AuthScope("localhost", 8080, "realm"),
new UsernamePasswordCredentials(username, password)
);
HttpMethod theMethod = null;
StringBuffer sb = new StringBuffer();
if ("GET".equalsIgnoreCase(method)) {
theMethod = new GetMethod(urlpath);
} else if ("POST".equalsIgnoreCase(method)) {
theMethod = new PostMethod(urlpath);
}
theMethod.setDoAuthentication(true);
try {
httpclient.executeMethod(theMethod);
sb.append(theMethod.getResponseBodyAsString());
System.out.println("JSon Result: => " + sb.toString());
return sb.toString();
} catch (Exception e) {
throw e;
} finally {
theMethod.releaseConnection();
}
}
-
3. Re: how to find processDefId by rest commands?
badtea Aug 10, 2014 1:40 PM (in response to greenday_ra)Hi Reza,
I agree that adding the JaxbCommandsRequest to your application would add some complexity that you may not need.
However, I was thinking the JaxbCommandsRequest is really an XML object. (See the code for it here). I was hoping that I could just write the XML as a string in the REST call. For example, I use the HttpRequester plugin for Firefox to test REST calls. I was hoping I could just put the XML into the content of the REST call. See the screenshot below for an example. (The XML in the screenshot is just my guess. I do not know the actual XML that would be needed.)
I don't know if my plan would work, though. I don't know enough about REST web services.
I will be experimenting with this soon. I will let you know if I get it working.
HTH
-
4. Re: how to find processDefId by rest commands?
decimerulo Oct 17, 2014 11:47 AM (in response to badtea)Hello Travis, thanks for the example,
but in my rest client this not work
<command-request>
<get-process-ids/>
</command-request>
return somthing like this:
<command-response>
<exception index="0"><status>FAILURE</status><command-name>
GetProcessIdsCommand</command-name><message>
DeploymentNotFoundException thrown with message 'No deployment id supplied! Could not retrieve runtime to execute GetProcessIdsCommand'</message><stackTrace>
org.kie.remote.services.exception.DeploymentNotFoundException: No deployment id supplied! Could not retrieve runtime to execute GetProcessIdsCommand at org.kie.remote.services.cdi.ProcessRequestBean.doKieSessionOperation(ProcessRequestBean.java:170) at org.kie.remote.services.cdi.ProcessRequestBean.processCommand(ProcessRequestBean.java:132) at org.kie.remote.services.cdi.ProcessRequestBean$Proxy$_$$_WeldClientProxy.processCommand(ProcessRequestBean$Proxy$_$$_WeldClientProxy.java) at org.kie.remote.services.rest.ResourceBase.restProcessJaxbCommandsRequest(ResourceBase.java:69) at org.kie.remoif I add the deployment-id return
<command-request>
<deployment-id>com.bc.solicitarCotizacion:solicitarCotizacion:1.0</deployment-id>
<get-process-instances/>
</command-request>
only works this xml:
<command-request>
<deployment-id>com.bc.solicitarCotizacion:solicitarCotizacion:1.0</deployment-id>
<find-process-instances/>
</command-request>
but return the history of process, I need only the ProcessID ACTIVE, is there any way?
thanks.
Mauro.
-
5. Re: how to find processDefId by rest commands?
badtea Oct 21, 2014 1:18 PM (in response to decimerulo)Hi Mauro,
Thank you for trying my example. I was not sure if it would work.
In the JBPM docs I found there is another command called "FindActiveProcessInstancesCommand". I have not tried this command, but maybe it will do what you want.
HTH
-
6. Re: how to find processDefId by rest commands?
decimerulo Oct 27, 2014 2:18 PM (in response to badtea)Thanks Travis.
I can't believe, I need something as simple as a service REST that return a list of Process Definition ID's but I can not find documentation.
I will continue looking for documentation or examples
thanks again!
Mauro.
-
7. Re: how to find processDefId by rest commands?
badtea Oct 27, 2014 5:01 PM (in response to decimerulo)Hi Mauro,
Did you try the "FindActiveProcessInstancesCommand" command? You would put it in the XML request, similar to how you were doing it above. I have not tried it myself though.
HTH
-Travis
-
8. Re: how to find processDefId by rest commands?
swiderski.maciej Oct 29, 2014 4:15 AM (in response to badtea)I believe in version 6.1 there should be a dedicated REST resource that returns all process definitions:
http://localhost:8080/jbpm-console/rest/deployment/processes?pagesize=20
that should give you quite few information about each process definition given user has access to.
HTH