[SCXML] Using <send> to call a REST API

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[SCXML] Using <send> to call a REST API

Diptendu Dutta
Is it possible to use the <send> tag to call a REST API?

How would one specify the various attributes such as method (GET/POST),
headers, body, etc.?

Is there any example code that I can consult?

Regards,

Diptendu Dutta
Reply | Threaded
Open this post in threaded view
|

Re: [SCXML] Using <send> to call a REST API

Woonsan Ko-3
Hi Diptendu,

On Mon, Mar 11, 2019 at 2:06 AM Diptendu Dutta <[hidden email]> wrote:
>
> Is it possible to use the <send> tag to call a REST API?

Possible.

>
> How would one specify the various attributes such as method (GET/POST),
> headers, body, etc.?

You can pass any data in <send> to the target, and your
EventDispatcher may interpret the data to invoke an external service.

>
> Is there any example code that I can consult?

WizardsTest.java [1], to handle a custom type of send event used in
wizard-02.xml [2], registers a custom EventDispatcher which can read
type, target and data, and possibly invoke an external service.

FWIW, this is beyond the question, but it might be interesting to
implement a generic EventDispatcher to integrate with Apache Camel,
simply dispatching to a specific route based on <send> attributes.
e.g, type="camel" data="...", where data is passed to a Camel route as
message body.

Regards,

Woonsan

[1] https://github.com/apache/commons-scxml/blob/master/src/test/java/org/apache/commons/scxml2/WizardsTest.java#L62
[2] https://github.com/apache/commons-scxml/blob/master/src/test/java/org/apache/commons/scxml2/env/jexl/wizard-02.xml#L43

>
> Regards,
>
> Diptendu Dutta

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]