Which is the best way to stablish communication... passing data between web services? I've develop a web service that treats data and the other web service has to perform another data treatment. So I need to make the second web services able to read data from the first.
(I've followed the example of the address book that comes in the labview examples, but I don't understant really well how it works)
The address book example uses a file to store information, and multiple web methods within the same web service read the file. Depending on your needs, there may be a better way to achieve what you want.
Do you want to pass data between two VIs in the same web service (like the example) or is it actually two different web services? Is it possible to use a stateless architecture instead (so the first web method sends the processed data back to the client, and the client then sends the data to the second web method)?
One way to pass data between two VIs in the same web service is to store the data in an auxiliary VI, which runs in the background when the web service loads, using functional global variables. Then your web method VIs can communicate with the auxiliary VI using, for example, a named queue. One advantage of doing it this way is that it also allows for asynchronous data processing such as periodically saving the data to a file.
I can give you more details if it looks like this is heading in the right direction for you. This is a great question about web service architectures.
Thank you for this first answer. The first thing that came to my mind is to use two different web services (one VI each), but I didn't realize that I could use two (or more) VIs in the same web service. So, what I'm looking for is to pass data between two VIs in the same web service! This could be a desirable solution. Is it possible to achieve this without using an auxiliary VI?
Data should be passed in the same way: once the first VI o method has performed data treatment, the resulting set of data has to be treated in the second VI or method. So data has to be treated by sets, all data together, first in one VI and then in the other VI.
Here's a possible architecture (we are actually using):
- A web service receives a request from the web
- The web service sends the data via UDP on a "worker" that is running on the same machine
- The "worker" treats the data and sends the result via UDP back to the webservice
- The web service vi packs the reply to the user and sends it back to the user
Hope it helps,
Ok if you want to pass data between two vi's in same web service,
you can do as pspangler told.
Create two vi's in which First vi's output has to be transferred to
second vi's input.I think this is what you want.
For this you can store the output in Functional global variable[FGV].
Create web service with two web methods one for each,when you request the first web method
it be processed and result will be stored in FGV. When you request for second web method,
it will retrieve data from FGV and do processing and get the result back in browser.
I think FGV can be added in always Included VI's in Source files. It works for me.
Or else you can write your own web server.
To store data that both VIs can access, Aarthi's idea is easy to implement. You can create a simple sub-VI with a functional global variable so that one VI would set the data in the sub-VI, and the other would get the data from the sub-VI.
Keep in mind that multiple clients could access your web service at the same time. Make sure you consider in your design what would happen if the first VI gets called twice in a row before the second one gets called at all. Also, using a sub-VI this way only works if you leave the "Load VI at startup" box checked when adding your VIs to the web service build specification.