I’ve deployed the Dinner decision table from the get-started pages, onto an EC2 server and I want to call it from a BPMN process I’m running locally.
I looked at the example for Rest calls for calculating whether it’s a holiday on github. Where I’m stuck, is that this example didn’t have a payload. With the dinner decision table I need to pass through the number of guest and the season:-
Can someone point me to a reference for doing this in the BPMN file or just show me the format which also includes using process variables and not actually hard-coding Spring and 2 guests.
Finally, generally speaking why are all the examples in java? Isn’t the plus part of BPMN that you can change the diagram to change the process? Not a criticism, just trying to learn.
When using the HTTP-Connector, you use “payload” in the connector’s input parameter.
Create a JSON string for the returned value of payload using JS or Groovy.
Can also take a look at:
the above provides a working example of a POST web service call, building a JSON payload, and parsing the response.
I’m confused as to what you’re asking here. Are you asking what a payload would look like to invoke the “dinner” example (I’ve worked with that also) or are you asking how to code variable inputs in the BPMN code itself?
The Dinner example outputs some things to the system/server log (essentially a deployment check to ensure that the deployed DMN is viable), but also returns a response to a REST request to the DMN when you ask to evaluate a set of inputs.
I was asking for both, The dinner decision service works when I call it using chrome’s Advanced Rest Client. It’s now a case of working how how to call that decision service from a locally executed process.
I thought that I would be coding everything inside of the BPMN but Ive obviously been working with a very old version of Camuda Modeler (now rectified) and I wasn’t aware until I read Steve’s post that you can set this inside the modeler.
I was able to call the decision service using hard coded values the following way (confirmed by checking the cockpit on the amazon server)
I wasn’t able to get through to the decision service. (BTW what does the “q” bit mean?)
I’m still working through this (slowly) so I might get some more answers (and questions) later, especially when it comes to processing the output of the decision (desiredDish).
Also @theHornet your life will be much happier if you build your JSON as a Js Object with dot notation, and then convert with JSON.stringify(); at the end. Much easier to maintain.
That is correct as the type for guestCount is specified as an integer, however the payload i used (pasted from above) in Chrome Advanced Rest Client worked fine. The call from the local process to the cloud decision works as well (with the hard-coded payload version) as checking on the cloud cockpit I can see that it was called and that the correct output was returned.
By using response.elements().get(0) I got rid of that message, and in fact was able to load the contents of the response payload into the variable “grub”.
From the first link, I’ve tried a few combinations on top from the link you provided such as:-
var json = S(response).elements().get(0);
var customerProperty = json.prop("desiredDish");
var customers = customerProperty.elements();
var customer = customers.get(0)
var grub = customer.value();
and got the following message:-
The process could not be started. :
SPIN/JACKSON-JSON-01002 Expected 'SpinList', got 'OBJECT'
Combinations on the inline script brought back the same error number 01002. I think that I’ll be able to extract the value using an external javascript file, but it’s a pain.
@theHornet you need to read the JSON Spin documents, and read up on the difference between a JSON Object and JSON array. you are using var customers = customerProperty.elements(); which is trying to get the array elements, but customerProperty is a object and so .elements() is not correct.
Should be something like:
var grub = S(response).elements().get(0).prop("desiredDish").prop("value").value();
Yes, that worked a treat. I’m not a programmer more of a tinkerer but I can see that I’m going to have to understand this difference between JSON objects and arrays.
I am using the parameter “var json = S(response, ‘application/json’);”, as the output of my connector, but I would like to filter the result, instead of show all the Json. Do you know you to filter the result?
This is the Json returned.
[
{
“nomeCliente”: “Andre Sousa”,
“documentoCliente”: “123456789”,
“codOrigem”: “332”,
},
{
“nomeCliente”: “Lucas Rodrigues”,
“documentoCliente”: “111111111”,
“codOrigem”: “112”,
}
]