Java Rest Client Query

Hi,

Just trying to get started with the REST api from a java client (SE currently).

I have found the following reference:
https://groups.google.com/d/msg/camunda-bpm-users/B-MNgFIofKM/c92IQTOGiQIJ

This looks like a good pointer, but I am not too familiar with JAX-RS, my trials have returned 404 errors (among other things - is there an easy way to turn more logging on to see the incoming request URLs to the server?).

Note, I have got the Rest API going returning pure JSON strings, but am hoping to be able to use the existing engine rest classes to feed the JSON into (rather than building new objects and parsing the JSON into (either manually or via Jackson or whatever)).

I am just wondering if anyone has any pointers to examples to help get me going. I am currently using Java SE, is there any boot strapping required to get it all working?

Finally, the reference mentioned was over a year ago. By chance, has a Java Rest Client API been developed anywhere?

Thanks for any help…

Colin

Hi,

there wasn’t a REST client developed in the mean time. And also I’m not aware of an example for this. But to help you to get your code working please provide more information on which application server you are using and what your code looks like that returns the 404.

Cheers,
Sebastian

Hi Sabastian,

Thanks for your reply. I have managed to make some progress (outlined in another post) with code like the following (on Tomcat):

public static void printoutSingleDef3() {
    Client client = ClientBuilder.newBuilder().build();

    for (Class<?> clazz : CamundaRestResources.getResourceClasses()) {
	client.register(clazz);
    }

    for (Class<?> clazz : CamundaRestResources.getConfigurationClasses()) {
        client.register(clazz);
    }

    WebTarget target = client.target("http://localhost:8090/engine-rest/process-definition/key/myTestProcess");
    ProcessDefinitionDto value = target.request().get().readEntity(ProcessDefinitionDto.class);

    System.out.println(value.getKey());
    System.out.println(value.getId());
    System.out.println(value.getResource());
}

This works, but ideally it would be nice to be able to call the Rest api classes more directly. As mentioned, my Rest knowledge is pretty limited, and in my attempts I was getting 404 errors as my target and rest urls obviously were not aligned. Is it possible to get something like the following working:

WebTarget target = client.target("http://localhost:8090/engine-rest"); // Maybe engine-rest should not be included in url?
/// ...some code to bind the target to the rest service...
ProcessDefinitionRestService service = ???

ProcessDefinitionResource resource = service.getProcessDefinitionByKey(myTestProcess);
resource.getFormVariables();
// etc

The link I mentioned initially refers to RestEasy / Apache CXF and their rest api proxy client feature… I am just not sure how to put it all together.

Thanks for any help. (I am also looking at having the client on the same server as Camunda so may be able to just use the Java api and avoid rest all-together, but think it will still be handy to have a reasonably easy way to call the rest api).