Modeling Guide

Response Invoker

The util.responseinvoker can be used to invoke the response callback to dliver a response message to the initiator of a request response invocation. This examples shows how this operator can be used with openapi.server and a custom operator to deliver the response to the http request.

Configure and Run the Graph

Follow the steps below to run the example from the Data Pipeline UI:
  1. Start the graph. This demo service will be started at path /openapi/service/samples/respinvoke relative to the vflow instance URL.
  2. Open the UI from the wiretap operator so that the request messages are displayed on the browser.
  3. From some REST client, send a POST request to /openapi/service/samples/respintercept2/echo with some text content. This service will echo the reversed text. When using curl, this would correspond to:
    curl -i -X POST -d 'some text' http://{host}:{port}/{path}/openapi/service/samples/respinvoke/echo
    For example, for a local vflow instance, use http://localhost:8090/ as in
    $ curl -i -X POST -d 'buenos dias' 'http://localhost:8090/openapi/service/samples/respinvoke/echo'
    HTTP/1.1 200 OK
    Access-Control-Allow-Headers: accept, content-type, authorization
    Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE
    Access-Control-Allow-Origin: http://localhost:8090
    Content-Type: text/plain
    Date: Wed, 11 Apr 2018 18:16:22 GMT
    Content-Length: 11
    
    said soneub
  4. Send another POST request with the wrong path to trigger an error (Note: the javascript operator returns an error if the request path is not /samples/respintercept2/echo).
    $ curl -i -X POST -d 'buenos dias' 'http://localhost:8090/openapi/service/samples/respinvoke/bad'
    HTTP/1.1 500 Internal Server Error
    Access-Control-Allow-Headers: accept, content-type, authorization
    Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE
    Access-Control-Allow-Origin: http://localhost:8090
    Content-Type: text/plain; charset=utf-8
    X-Content-Type-Options: nosniff
    Date: Wed, 11 Apr 2018 18:17:19 GMT
    Content-Length: 81
    
    Invalid path /samples/respinvoke/bad; Expect path /samples/respinvoke/echo
    $