LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically Start REST Web Service

I want to programmatically start and stop a REST web service in LabVIEW 2013.


I found information about how to programmatically build and deploy the web service.  However, this does not fit with the way I built my REST web service because I am using a newer version of LabVIEW: the REST service is not a Build Specification.

 

I also found this tutorial about how to programmatically start and stop the LabVIEW Web Server.  I tried this method and it does not work for me.  The reason may be because this tutorial is for an older version of LabVIEW.

 

I specifically want to start and stop an individual REST web service.  Right now this web service is associated with a GUI; when the GUI is running, the service is online and when the GUI closes the service goes offline automatically.


I want more control than this: I want to specify when to start and when to stop the service (for instance, when a user clicks a button).  I also noticed that the LabVIEW Application Server is always online (even when LabVIEW is closed) because I get a 404 response rather than a "could not resolve" browser error.

 

Is there a way to control when my REST Web Service is running?  Is there a way to control the LabVIEW Application Server?

 

Thanks!

Darshan

 

0 Kudos
Message 1 of 10
(4,848 Views)

Darshan,

 

There are no methods to start and stop LabVIEW web services programatically.  You can start and stop NI services programatically using the following method, although, I do not think this will provide the functionality you are looking for.

 

http://digital.ni.com/public.nsf/allkb/87FCE111FD854484862572FF007D252A?OpenDocument

 

Regards,

 

Shane C

Message 2 of 10
(4,770 Views)

Thanks Shane.


My NI support person provided the same feedback: there is no direct way to start and stop the REST service programmatically.

 

I may have an indirect way to start and stop the server.  Since the REST service is tied to an exe (that is, when the exe is running, the server is running, and when the exe is not running, the server is not running), I will be able to accomplish what I want by starting and stopping the exe.

 

Is this the best way to accomplish what I want?  If so, how do I start/stop an exe (the exe should run in the background, not show up in the taskbar, etc.)?


Thanks,

Darshan

0 Kudos
Message 3 of 10
(4,685 Views)

Darshan,

 

Yeah, I believe your method would indeed allow you to programatically stop and start the web service.  The easiest way I can think to do this is to use the System Exec.VI to start the process, and then again to kill that process.  Take a look at the following example that shows how to stop a process using LabVIEW.  

 

http://digital.ni.com/public.nsf/allkb/80432B061C5A4C888625705400737BE8

 

If you are building an executable and want to make it a background process, you will want to take a look at the following link:

 

http://digital.ni.com/public.nsf/allkb/EFEAE56A94A007D586256EF3006E258B

 

Regards,

 

Shane C

0 Kudos
Message 4 of 10
(4,663 Views)

For the stopping part, you could implement a special command to shut down, e.g. Post "Quit" or similar, since i assume the service stopping if the .exe exits. 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 10
(4,649 Views)
Fast forward to 2017. Is this functionality available now?
0 Kudos
Message 6 of 10
(4,146 Views)

This user referenced this page and mentioned it didn't work for them (without giving too many details besides that the tutorial was written for an older LabVIEW version). You can still access the properties referenced. Have you tried these steps in a more current version than the original poster? Does it give you an error?

0 Kudos
Message 7 of 10
(4,121 Views)
@DahlmanR - These steps work as-is on my LabVIEW 2015, yet what this achieves (from what I saw) is starting the "admin interface" of the server, but not a specific service - which is what I need. I am looking for an automatic way to do the equivalent of right clicking on the service, and then start.
0 Kudos
Message 8 of 10
(4,119 Views)

Am I correct assuming you used this VI at this link and this did not allow you to start you start a particular service?

 

http://digital.ni.com/public.nsf/allkb/87FCE111FD854484862572FF007D252A?OpenDocument

0 Kudos
Message 9 of 10
(4,098 Views)
@Letitsnow - No, I did not use that VI. My problem is starting a RESTful service - not a *windows* service, and not the *application server*. It is explained in more detail here: http://stackoverflow.com/q/42806879/3372061 . Thanks
0 Kudos
Message 10 of 10
(4,093 Views)