This example demonstrates how to use a WebVI to communicate over networks with SystemLink Tags after connecting to SystemLink Cloud or SystemLink Server, an on-premises web server.
Once you complete the necessary steps, you will know:
From the panel of the web app, you will be able to:
Figure: When hosting a WebVI on the NI Web Server, you do not need to supply credentials again once you logged into the SystemLink web interface.
To use SystemLink data services, you need one of the following product combinations:
Use NI Package Manager to install the products you need. If you do not have NI Package Manager, download and install the latest version now.
Do you want to learn about connecting your web application to SystemLink Cloud or SystemLink Server? Click one of the following links to jump to your workflow:
In this section, you’ll learn how to set up, build, and connect your web application to SystemLink Cloud from G Web Development Software.
To connect your web application to SystemLink Cloud from G Web Development Software, you need a server URL and an API key. The API key authenticates the web application running on your local machine for SystemLink Cloud – much like your ni.com credentials authenticate your identity.
Learn how to establish a connection to SystemLink Cloud from G Web Development Software.
Figure: Note the input differentiation between connecting to the SystemLink Cloud server from LabVIEW or G Web Development Software vs. hosting your web application on SystemLink Cloud.
An API key authenticates an application trying to access SystemLink Cloud. It helps to think of an API key like login credentials. When you log in somewhere, your username and password authenticate who you are and, if they’re correct, grant you access. An API key functions similarly for your application connecting to the SystemLink Cloud server.
Note: You only get to see an API key once, so keep it somewhere safe and only provide it to those you trust. If you delete an API key, all applications using that API key will no longer be able to connect to SystemLink Cloud.
To connect to SystemLink Cloud from G Web Development Software, you need a server URL and an API key.
Note: You will only see the API key once, so keep it somewhere safe.
Tip: Use the Web Application Project template to easily create a WebVI. Navigate to the Projects tab and click Web Application Project to launch it.
Note: You can also change the Function configuration in the Item tab of the Configuration pane.
https://api.systemlinkcloud.comas the server url.
index.gviweband click Run.
After you create a web application and build the package in G Web Development Software, you need to deploy it to a web server so that others can access it using a web browser.
To upload a WebVI to SystemLink Cloud, you will need to build it into a package file, which can be uploaded to SystemLink Cloud. This project includes a distribution document (
Full Data Services App.lvdist), which can be used to build a package (
Full Data Services App.lvdistto open it.
See packaging an application if you’re interested in learning more about distributing applications.
For SystemLink Cloud to host your web application, use your ni.com credentials for authentication.
Note: Leave the api key and server url inputs empty to minimize security vulnerabilities.
In this section, you’ll learn how to set up, build, and connect your web application to the SystemLink Server, an on-premises web server.
Figure: Note the input differentiation between connecting to an on-premises server from G Web Development Software vs. hosting your web application on the NI Web Server.
To connect to the SystemLink Server from LabVIEW or G Web Development Software, you must include a server url (i.e.
https://systemlinkcloud.com), a username, and a password. The username and password can be managed with the NI Web Server Configuration utility. This utility can be used to create new users and groups as well as leverage existing LDAP or Windows user accounts.
When a web application is hosted on the SystemLink Server, leave the server url, username, and password inputs empty to minimize security vulnerabilities.
Note: If you use your own web server, you will need to include your credentials for SystemLink Cloud or SystemLink Server to authenticate the data services in the web application.
After installing G Web Development Software, you need to install and configure a SystemLink Server. SystemLink Server includes NI SystemLink Web Application.
Note: If the NI Web Server Configuration doesn’t launch automatically, follow this path:
C:\Program Files\National Instruments\Shared\Web Server Config.
Note: This makes the user an admin for SystemLink data services. It also makes the user an admin for Windows.
Note: This example assumes port 9090 is chosen.
index.gviweband click Run.
Full Data Services App.gcompto open it.
After you create a web application and build the package in G Web Development Software, you need to move it to a web server. This enables administrators to access it from a web browser. Copy your entire web application output directory to any web server you choose.
Note: To navigate to your web application output on your machine, click Locate directory in Windows Explorer on the Document tab of your web application component document. You can also access the build output by navigating to your web application’s project folder manually (
Furthermore, this project includes a distribution document (
Full Data Services App.lvdist), which you can use to build a package (
.nipkg). A package is also required for hosting a web application on SystemLink Cloud. See packaging an application to learn more about distributing applications.
Follow the instructions below to host the web app on a web server.
Full Data Services App.lvdist.
Note: The button looks like a hammer.
.nipkg) and follow the on-screen instructions.
C:\Program Files (x86)\National Instruments\Shared\NI WebServer\www.
Full Data Services App_Web Serverdirectory into the
wwwdirectory of the LabVIEW web server.
C:\Program Files\National Instruments\Shared\Web Server\htdocs.
Full Data Services App_Web Serverdirectory into the
htdocsdirectory of the NI Web Server.
The Call SystemLink Data Services examples uses tags and messages, which are a part of the SystemLink data services API. The Tag API is a highly scalable, lossy network commutation method that utilizes a central node to broker communication between distributed embedded, desktop, and web applications. Use Tags nodes to send and receive measurement data from one system to other systems.
The Message API communicates between systems with strings by publishing messages to topics and allowing subscribers of those topics to receive the messages. The Message API works like a queue. Therefore, if a publisher writes three messages, the subscribers dequeue and read those messages one at a time. Use Messages nodes when you need to send warning messages, status updates, or trigger events from one system to other systems.
Refer to the SystemLink API Docs to find out more about the SystemLink data services API.
index.gviwebto learn how these APIs can be assembled into an interactive application.
Basic Data Services.gcompfor a simple overview of these APIs.
..\CallSystemLinkDataServices\LabVIEWExamples\LabVIEWExamples.lvprojto see how you can interact with SystemLink and SystemLink Cloud from LabVIEW and LabVIEW Real-Time.
For the sake of approachability and learnability this example includes username and password fields on its panel. We discourage this practice for all applications used in production.
Additionally, authentication credentials should not be stored in constants on the web application’s diagram. Storing credentials, such as usernames, passwords, or API keys, on the diagram could allow a malicious attacker to retrieve them by accessing the code running in the browser. We encourage you to store your credentials securely on disk but accessible via HTTPS. For example, credentials could be stored in a JSON file within the web server that is also hosting your web application.
If storing credentials in a file is not an option and you need to host your web application on-premises, you may choose to host your web application in the NI Web Server. This requires users to login to the SystemLink Web UI for authentication. Logging into this Web UI stores an authentication cookie in your browser that is automatically sent with calls to SystemLink data services. This eliminates the need to enter a username or password directly to the WebVI, either on its panel or its diagram. To do this, put the built output of your web application into the directory found at
C:\Program Files\National Instruments\Shared\Web Server\htdocs. This is the directory for all files hosted by the NI Web Server. Please note a user can access the URL of the web application without logging in, but in order to read/write tags, they will have to login to the SystemLink Web UI at
If storing credentials in a file is not an option and you can host your web application in the cloud, you may choose to host your web application on SystemLink Cloud. This requires you to have an active SSP for the G Web Development Software and an ni.com account. Doing so allows an authentication cookie in your browser to be automatically sent with calls to SystemLink Cloud. This eliminates the need to enter an API key or server URL either in the web application.