-
1. Re: Service Task - REST example
marcj Mar 19, 2014 6:01 AM (in response to oiler)Hi Kalleen,
I´m currently working on the same issue. A simple test case would be a call to this REST service:
http://www.webservicex.net/currencyconvertor.asmx/ConversionRate?FromCurrency=EUR&ToCurrency=USD
I´d like to set the two currency parameters provided in the URL in the jBPM process. I also didn´t succeed with the REST Service Task yet.
Did anyone ever implement a REST service call and could provide some support? -
2. Re: Service Task - REST example
oiler Mar 19, 2014 6:47 PM (in response to marcj)Yeah there needs to be some way to put variables in the URL. I know you can set process variables is there any way those can be inserted into variables in the URL for the task? For example
http://www.webservicex.net/currencyconvertor.asmx/ConversionRate?FromCurrency={From}&ToCurrency={To}
-
3. Re: Service Task - REST example
oiler Mar 19, 2014 10:51 PM (in response to oiler)From what I can gather the provided REST Task is fairly simple and to build something more sophisticated requires building a custom work item handler which is described here.
-
4. Re: Service Task - REST example
marcj Mar 20, 2014 2:51 AM (in response to oiler)Still, calling a REST service with a URL containing variables set in the business process should be a fairly simple task and therefore sould be possible without extensive coding, right? I wonder if someone can provide some more information regarding both WS and REST service tasks.
-
5. Re: Service Task - REST example
oiler Mar 20, 2014 6:36 PM (in response to marcj)I hear you just not sure that's supported presently. I'm working on getting a simple REST call going with the provided REST service task then will try code up a more flexible one and report back.
-
6. Re: Service Task - REST example
oiler Mar 20, 2014 8:51 PM (in response to oiler)I found this below in the jBPM 6 user guide section 6.6.1. Variables. Not sure if it applies in our use case where we want to modify a URL. I will try it out.
Service tasks (and reusable sub-processes) can pass the value of process variables to the outside world (or another process instance) by mapping the variable to an outgoing parameter. For example, the parameter mapping of a service task could define that the value of the process variable x should be mapped to a task parameter y right before the service is being invoked. You can also inject the value of process variable into a hard-coded parameter String using #{expression}. For example, the description of a human task could be defined as You need to contact person #{person.getName()} (where person is a process variable), which will replace this expression by the actual name of the person when the service needs to be invoked. Similarly results of a service (or reusable sub-process) can also be copied back to a variable using a result mapping.
-
7. Re: Service Task - REST example
marcj Mar 21, 2014 8:25 AM (in response to oiler)Hi Kallen,
would be very interested if you did succeed.
I implemented the aforementioned ConversionRate web service with a custom event handler, so if you'd be interested I can outline my solution. WIth a WSDL though, not with REST. I still try to figure out how a custom REST work item handler has to be implemented.
-
8. Re: Service Task - REST example
oiler Mar 27, 2014 11:34 PM (in response to oiler)Just getting back to this. So when I create a simple one task process that makes a simple REST call I get the following error message.
Process Instances failed to start: [examples.restexample:42 - REST:3] -- java.lang.String cannot be cast to java.lang.Integer
How do I go about debugging this? According to org.jbpm.process.workitem.rest.RESTWorkItemHandler (http://docs.jboss.org/jbpm/v6.0/repository/Rest/) it doesnt take integers as parameters and only the URL must be specified.
Under "Assignments" for the REST task I set the "To Value" or the Url parameter to the endpoint I'm trying to reach, am I missing something?
-
9. Re: Service Task - REST example
swiderski.maciej Mar 31, 2014 1:21 AM (in response to oiler)here you can find test cases for REST work item handler that should give you all the details needed to operate on it.
HTH
-
10. Re: Service Task - REST example
oiler Mar 31, 2014 5:16 PM (in response to swiderski.maciej)Maciej thanks for your help. Sorry I wasn't clear up above but I'm trying to build and run my use case within the KIE Workbench. It should be just a matter of going to the task properties then under "assignment" setting the URL under the "To Value" correct? Any idea why the task, according to the error message, is expecting an Integer?
Thanks
-
11. Re: Service Task - REST example
oiler Mar 31, 2014 9:09 PM (in response to oiler)I managed to get this working in the KIE workbench along with the variable injection. I ended up removing the optional DataInputs and assignments so all I was left with was the Url and method. Must be a mapping problem there with the default optional parameters. For the Url assignment I was able to inject a process variable into the Url at runtime.
i.e.
-
12. Re: Service Task - REST example
swiderski.maciej Apr 1, 2014 7:25 AM (in response to oiler)I believe you ran into this issue. Will be fixed soon but as workaround removing the optional parameters would do the trick (as you have already confirmed).
HTH