question

Yue Y avatar image
0 Likes"
Yue Y asked Phil BoBo edited

How to make asynchronous call to web service

Hi, I am considering using a web service inside FlexSim. After reading https://answers.flexsim.com/questions/21092/web-communication-within-flexsim.html. I know FlexSim is capable of sending HTTP request and response. But I don't want FlexSim to be blocked on the HTTP call, instead, my goal is to let the simulation continue and react to the response asynchronously. For example, say there a source creating 1 token every one second, the token is sent to a processor. The logic inside the processor is, sending a request to a remote web service and the token should leave the processor after receiving a response. While waiting for the response, FlexSim shouldn't freeze. The source should continue emitting tokens and the process should keep accepting tokens.

I am thinking about using a background thread listing to responses and updating tokens' state accordingly, the processor will react to the tokens' state.

Is the possible?

FlexSim 19.1.0
custom codewebserverhttpweb communicationsynchronization
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Jacob Gillespie avatar image
3 Likes"
Jacob Gillespie answered Phil BoBo edited

An asynchronous call could be achieved by letting an html GUI element handle it. I am thinking you could create a hidden html view and use callwebscriptmethod() to start the request, and then use fireFlexscriptEvent() from Javascript to get the response back to FlexSim.

Here is a sample model with both of those methods.


· 8
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.