What LabVIEW web services can do for you: An in depth guide to building web services into your applications and deploying them to your target machines.
Oct 28, 2014
What LabVIEW web services can do for you: An in depth guide to building web services into your applications and deploying them to your target machines.
Design test automation systems in LabVIEW for last 16 years. Medical Telecomm Software (using COM interfaces, XML) Network Servers (multiple simultaneous asyncronous
DUTs from single TE) Using LabVIEW since 1993 (version 3.1). EE from MTU. Know some C, C++, C#,
JavaScript but prefer LabVIEW. Believe there is nothing you can’t do in LabVIEW
(if you try hard enough!)
Wikipedia: “a software system designed to
support interoperable machine-to-machine interaction over a network.” (http://en.wikipedia.org/wiki/Web_service)
National Instruments: “more open and standard way to communicate with VIs
over the Web.”
My Definition: An API that allows (nearly) any language or tool to
interface with your application.
NI.com Links
Web Services in LabVIEW
▪ http://zone.ni.com/devzone/cda/tut/p/id/7350
LabVIEW Web Services FAQ
▪ http://zone.ni.com/devzone/cda/tut/p/id/7747
LabVIEW Web Services Security
▪ http://zone.ni.com/devzone/cda/tut/p/id/7749
Web Service Build Specification Builds lvws file
RESTful Web Server Must be enabled when testing in IDE
Must be disabled to build for distribution Sending Parameters Must include httpRequestID if returning stream data
Pitfalls▪ Cannot send case sensitive data (converts everything to lower case)
▪ Cannot send file paths (must use substitute for /, I like to use ~)
▪ Cannot send file names at end of call (browser will think it points to a file)
Returning Data
XML Format
Text Format
HTML Format
Streaming MIME data
Application Instances you must understand:▪ The Web Service Instance
▪ This is the app instance of the LabVIEW exe that has the web service enabled in its ini file. The NI Web Server Service is on port 3364.
▪ The IDE Instance▪ Always on port 3363 (unless you changed it). Will block any other app
on same port.
▪ Your EXE Instance▪ Recommend using a unique port number.
Connecting to the right instance▪ Must Use IP (demo of how to get this programmatically)
▪ Must have VI Server Enabled and set to unique port. (Must set this in the EXE ini file)
Cannot use normal methods (queues, notifiers)
Calling interface VI with VI Server
VI must be in memory (how to accomplish this)
▪ See EXAMPLE - EXE with screenshot enabled.vi
VI can push data into a queue.
How to use queues to wait for a response (demo)
Calling a web service from LabVIEW
Converting the XML into an Array of Clusters
▪ (see call web service.vi for demo)
Calling your web service from HTML
Demo of F5 test system web interface
You can use any web enabled script or language to call your web service (makes your application ‘scriptable’)
Building a web service into an application
Build Specification (the order in the project is important!)
▪ Turn off the Web Server before you build
Custom Files you must include
▪ niwebserver.conf (how to create and edit, MIME issue)
▪ The www folder (and how to make it appear)
Setting up the Installer
Passing in data (discussed above) Niwebserver.conf file tweaks The build process is a PITA (and very non-intuitive).
Seems like distribution was an afterthought. Hope for the future?
Double Installation issue Log folder missing
C:\Program Files\National Instruments\Shared\LabVIEW Run-Time\8.6\webserver\logs
Hard to debug! Must build with diagrams included (Source File Settings) and
breakpoints already set. Distributed System Manager
▪ Refresh does not work▪ URL path display sometimes works, sometimes not
Where to get it:▪ http://lavag.org/index.php?app=downloads&showfile=80
What does it do? Runs as a Windows service (project docs explain
how this is done)
Keeps the RESTful web server up and running. (see ini file)
Deploys new web services you install automatically
Provides some cool utilities!
Test the web server
Echo
Get a screenshot
Remote screen must be rendered (active user)
Get the front panel image of any VI
VI must be in memory
Get the version of any EXE
EXE must be running
Demo using iPod
Create a Universal API Can access any LabVIEW application
anywhere in the world Multiple access methods Not simple (yet) to use, but should get better Hard to debug! Only limited by your imagination…