Simplest way to call a JAX-RS service from a Camunda ServiceTask?

355 views
Skip to first unread message

Alfonso Mateos Alarcón

unread,
Jan 14, 2014, 4:05:51 AM1/14/14
to camunda-...@googlegroups.com
Hi guys,

First of all, thanks a lot for your great job with Camunda, it's getting better every time, and really fast.

My question is about calling our REST services (implemented with RestEasy) directly from Camunda, without needing a JavaDelegate class 
When it comes to call Camel, for instance, things are really simple, like this: #{camel.sendTo('direct:syncService')}.
Is there a way to call a REST web service in an equivalent way?

In case it isn't, which would be the simplest way to do so? If possible, we'd rather prefer the JEE way, don't know if the recommended could be instantiating a jax-rs client bean and then dealing with it as if it was a regular bean.

My intention for this question is to have the simplest possible code in my app, so that maintenance is easier, and keep the code as little as possible.

I'm looking forward to your clarifications. 
Thanks a lot in advance!

Christian Lipphardt

unread,
Jan 14, 2014, 6:12:35 AM1/14/14
to camunda-...@googlegroups.com
Hi Alfonso,

there is no standardized way to generate a REST client in JavaEE 6. It will be possible with JavaEE 7.
Either you use a library like Apache HTTPClient to invoke your REST endpoint or when you aren't afraid of being lib-locked, you can use the REST client feature of RestEasy (see RestEasy documentation).
Using camel is also an option.

Cheers
Christian

Alfonso Mateos Alarcón

unread,
Jan 14, 2014, 7:17:10 AM1/14/14
to camunda-...@googlegroups.com
Hi Christian,

Thanks for your answer. As a workaround to the limitations you expossed, I wonder if it could be useful to instantiate a cxf proxy for a REST service, like this:
<jaxrs:client id="restClient"
       address="http://localhost:${testutil.ports.BookServerRestSoap}/test/services/rest"
       serviceClass="org.apache.cxf.systest.jaxrs.BookStoreJaxrsJaxws"
       inheritHeaders="true">
       <jaxrs:headers>
           <entry key="Accept" value="text/xml"/>
       </jaxrs:headers>
</jaxrs:client>

And then try to use the bean "restClient" from our Camunda Service Task treating it as a bean? I know it's instantiated from Spring, not thru JEE, but anyway...
Thanks a lot again :-)

Christian Lipphardt

unread,
Jan 14, 2014, 7:39:32 AM1/14/14
to camunda-...@googlegroups.com
Hi Alfonso,

as long as you use a SpringProcessApplication or derived class, it should be not problem to inject the Spring bean.

Cheers
Christian

Alfonso Mateos Alarcón

unread,
Jan 14, 2014, 11:20:47 AM1/14/14
to camunda-...@googlegroups.com
Thanks a lot!
Reply all
Reply to author
Forward
0 new messages