Send an HttpRequest without response in Progress OpenEdge

Discussão em 'StackOverflow' iniciado por fdantas, Julho 12, 2017.

  1. fdantas

    fdantas Administrator Moderador

    I am using IHttpRequest to send a request to a service that has to create a message. At this moment the Progress procedure holds until it receives a request from the service, while it should just continue. (Fire and forget principle)

    This is the class I use to make the call to the service:

    USING Progress.Lang.*.

    USING OpenEdge.Net.HTTP.ClientBuilder.
    USING OpenEdge.Net.HTTP.IHttpRequest.
    USING OpenEdge.Net.HTTP.IHttpResponse.
    USING OpenEdge.Net.HTTP.RequestBuilder.
    USING Progress.Json.ObjectModel.JsonObject.

    BLOCK-LEVEL ON ERROR UNDO, THROW.

    CLASS TOOLS.externals.zato.SendDesadv:

    DEFINE VARIABLE baseURL AS CHARACTER NO-UNDO.
    DEFINE VARIABLE servicePath AS CHARACTER NO-UNDO INITIAL send/json".
    DEFINE VARIABLE serviceURL AS CHARACTER NO-UNDO.
    DEFINE VARIABLE oRequest AS IHttpRequest NO-UNDO.
    DEFINE VARIABLE oResponse AS IHttpResponse NO-UNDO.
    DEFINE VARIABLE input_json AS JsonObject NO-UNDO.

    CONSTRUCTOR PUBLIC SendDesadv ( INPUT wave_nr AS INTEGER ):
    input_json = NEW JsonObject().
    input_json:Add("wave_nr", wave_nr).
    invokeZato(input_json).
    END CONSTRUCTOR.

    METHOD PUBLIC VOID invokeService( INPUT input_json AS JsonObject ):
    setServiceUrl().

    SESSION:DEBUG-ALERT = TRUE.
    oRequest = RequestBuilder:put(serviceURL, input_json)
    :AcceptJson()
    :REQUEST.
    oResponse = ClientBuilder:Build():Client:Execute(oRequest).
    END METHOD.

    METHOD PUBLIC VOID setBaseUrl( ):
    IF LENGTH(PDBNAME(2)) = 3
    THEN baseURL = "http://foo".
    ELSE baseURL = "http://bar".

    END METHOD.

    METHOD PUBLIC VOID setServiceUrl( ):
    setBaseUrl().
    serviceUrl = baseUrl + servicePath.
    END METHOD.
    END CLASS.


    I have already tried to just leave oResponse = ClientBuilder:Build():Client:Execute(oRequest). out of it, but then nothing is sent.

    How could I use the "fire and forget" principle here?

    Thanks in advance.

    Continue reading...

Compartilhe esta Página