From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

Auto Refresh for LabVIEW Web Service Using LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview

This VI shows how to share and refresh your front panel in the web browser.

 

Description

Are you using Web Publishing Tool to share your front panel over the web? Do you want to get a little more functionality out of it? This example mimics the functionality of the Web Publishing Tool mirror setting, but gives you more flexibility in terms of the appearance. This example was made with LabVIEW 2013, which has an object-oriented approach to web services.

The following stpe is the tutorial about how to build the required web service project.

Step 1: Create Web Service

  1. Open a Blank Project.
  2. Right-click My Computer and select New»Web Service.
  3. Give it a name.

Step 2: Add the VI You Want to Publish

  1. Right-click My Computer and select Add»File.
  2. Browse to the desired VI’s file path and click OK.
  3. Repeat for any other VIs that you want to publish over the web.

Step 3: Add the GetImage.vi

  1. Download this example.
  2. Add GetImage.vi to the project as was done in Step 2.
  3. Drag GetImage.vi into the Web Resources folder under the Web Service.
  4. There should be (GET) appended to the end of the VI’s name. Open GetImage.vi and change the file path constant in the block diagram to match the VI you are trying to publish.
  5. Save GetImage.vi and close it.

Step 4: Configure Web Service

  1. Right-click the Web Service created in Step 1 and select Properties.
  2. Click on HTTP Method VI Settings.
  3. Select GetImage.vi.
  4. Click the Output Type tab.
  5. Select Stream.
  6. (check or uncheck) Use Headers and Buffered.
  7. Click OK.

Step 5: Add a Static Web Page

  1. Copy the included Static folder to your project’s folder path. Make sure it contains the file index.html.
  2. Right-click the Web Service created in Step 1 and select Add Public Content Folder…
  3. Select the Static folder.

Note: this auto-populating subfolder will contain all web pages you want to host on this web service.

Step 6: Modify HTML Code

  1. Open index.html (located in the Static folder) in your favorite text editor. I like notepad or notepad++.
  2. In the Head Section, you can change the title or refresh rate to your own (currently the title is Web Service and the refresh rate is 5 seconds).
  3. In the Body Section, note the address of the images.  Change the address to match your server’s IP address. AND CHANGE THE WEB SERVICE NAME from WebServiceName to the name you gave it in step 2.
  4. Save and close the file.

 

Requirements

  • LabVIEW 2013 (or compatible)


Steps to Implement or Execute Code

  1. Run the VI you want to display in LabVIEW.
  2. Right-click the created Web Service and select Application Web Server»Publish.
  3. Wait for the build to complete and click OK.
  4. Right-click the Web Service and select Start.
  5. Double click index.html from the LabVIEW project.

 

Additional Information or References
VI Snippet of Block Diagram
BD.png

 

 **This document has been updated to meet the current required format for the NI Code Exchange.**

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
weeberp
Member
Member
on

Hello, can yo save in Labview 2012? thanks

www.elblogroboticodepedro.tk
ConnorM
Member
Member
on

weeberp,

This example uses the new features for web services in LabVIEW 2013. Sorry I can not back save it to LabVIEW 2012 with out rewirting it.

meddeb.safouene@gmail.com
Member
Member
on

hi ConnorM and thank you for this detailed work

i want to ask if i can use labview web service to upload data recovred from data base (numerical data) in an interface (done with other language not labview) and put each parameter in his specific fields

For example i recover the value of Temperature 1,2 and 3 and  i want to upload each one in his specific fields. If yes or No can you help me with some suggestions, documents video,examples ...

because i am beginner with labview

thanks