Jump to content

problem with HTTP, cookies and external web services(RESTful)

Recommended Posts



I have a problem with http VI’s and external web services (RESTful) and I’m using LabVIEW 2013.


In NetBeans I create a project with a GET web service from a table in MySQL, so I use http VI’s for accessing the service (blog diagram .png), receiving the information in JSON (front panel.png) and took the information I needed (in this case the “slActualValue†value).


I have a program that inserts new values in the database and in chrome the service works fine but if a want to do the Vi in a while loop to update or receive new values, the the next JSON data form the web service is the same as the first call, but if I go to the NetBeans project and do the deploy again the JSON data changes.


I ask about this problem from the experts in web services (RESTful) and they say that is the cookies in the LabVIEW program, so I create add a cookie file .txt but im not confident about the format of the file(the example is in this post) or if there something amiss in the LabVIEW VI’s


Cookie.txt file

# Netscape HTTP Cookie File

# http://curl.haxx.se/rfc/cookie_spec.html

# This file was generated by libcurl! Edit at your own risk.


UNKNOWN        FALSE      FALSE    0             ID           0



Link to post
Share on other sites

Cookies are set by the server. You are just telling the labview client where to store it so whatever you put in there will be overwritten at some point.


The data is probably being cached and you are getting the cached values. Try adding the folloing headers.


Cache-Control : no-cache, must-revalidate, max-age=0

Pragma : no-cache

Link to post
Share on other sites



I tried:


add the headers in VI, in the web service, disable the cache form the glassfish server and activate pool, lower the timeout of the cache and pool, but until now nothing  


Cookies are set by the server. You are just telling the labview client where to store it so whatever you put in there will be overwritten at some point.


The data is probably being cached and you are getting the cached values. Try adding the folloing headers.


Cache-Control : no-cache, must-revalidate, max-age=0

Pragma : no-cache

Link to post
Share on other sites

The labview webbrowser stuff is pretty crappy.


Use a .net webBrowser control, navigate, get the document and you can pretty much do what you want using standard .net calls, and really gives you better control over the browser (which is IE version on your machiene)


At this point you can pretty much google how to get stuff, just look to use visual basic or C# and follow the .net calls putting them in labVIEW.  




Get Webpage Stuff.vi

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Similar Content

    • By prabhakaran
      Does LabVIEW support kerberos authentication? If someone has worked in this, a snippet on how to do authentication would be of very much help. Any help in this regard is appreciated.
    • By OlivierL
      ShaunR's recent topic on Security reminded me of a situation we explored in the summer and need to revisit at some point. We were looking for a method to protect the communication with a cRIO.
      The situation is that we need to communicate between a cRIO and a host on an unsecured network (manufacturing environment.) We concluded that we needed some form of encryption as well as a standard login mechanism but identified that having a single symmetrical key would not provide enough protection (for various reasons and specific use cases.)
      Therefore, we looked into SSL and LabVIEW Web Services because it already includes that library and all the security features that we need. We figured out that it would definitely offer the protection required but that would mean rewriting most of existing code to use Web Service instead or establish some for of communication through a new Web Service. Considering the amount of unknown and risks associated with modifying our code, we looked into an alternative and came up with the following scheme:

      In short, we would use a Web Service for the initial login and create a new symmetrical key which would be passed to the host and to the main application on the target (cRIO) and would be used to encrypt/decrypt all data during the session. This way, we could still program all of our code in LabVIEW and easily download/deploy the services and applications to the Target using NI standard tools but benefit from proper security and only have to add fairly simple wrappers to some sections of our existing code.
      I wonder if anyone else has already gone down that route to add protection to an existing application. Would you suggest a different implementation method or an easier path to a similar result? Is there some obvious pitfalls in this approach that we do not see?
    • By Neil Pate
      Hi All,
      Can anybody shed some light on some strange behaviour I am seeing when deploying an executable with Web Services and Public Content.
      I have an HTML page that gets served up as part of my application. My LabVIEW application interacts with a browser via Web Services.
      Everything runs (mostly) fine, I can browse to localhost/ws/index.html and I get my web page.
      However, I would have expected that HTML (and JavaScript etc) would remain on disk in source form so I could edit it after the LabVIEW application has been built, but this does not appear to be the case. Changes I make to the source do not get reflected until I rebuild my LabVIEW application.
      Does the Public Content in the Web Service get packaged into either the .exe or the .lvws up as part of the build process?
      I am really perplexed by this. I have tried all the obvious things like clearing browser caches etc. I even tried using a brand spanking new browser that had never been installed on my PC and I got the same symptoms.
    • By chriscotton
      Hi guys, just wondering if it is possible to publish a web service with a control and simulation loop in the vi. I have a simulation loop and an output of an array and matrix of data from a signal, yet i can't seem to be able to deploy the vi at all. It will build but not deploy.
      Any help or advice would be most appreciated.
    • By Wim
      Hi Guys,
      It has been a while but I'm back :-)
      I'm having some 'problems' with http requests ....
      Project summary:
      LabVIEW 2010 Application that reads sensor logs from a database.
      The application gets its data via http requests: --> architecture of the project --> data must be accessible via web-service 
      Example: http://localhost:8085/sensorservice/sensor/test/temperature..... (and some paramaters about the amount of data to return.) is entered in the LabVIEWHTTPClient.lvlib:GET.vi and I receive my data in the body and header controls.
      So far so good.
      Every data request takes about 0.3 s Not bad .... but .... all sensors that are read in the application are handled sequentially in a FOR loop.  So 60 sensors *0.3s == 18s update rate.
      Not fast enough for my customer.
      The LabVIEWHTTPClient.lvlib:GET.vi is reentrant and it allocates an instance for each clone.  
      So i quickly made an active object for each sensor and call the LabVIEWHTTPClient.lvlib:GET.vi by ref with x08 as option when i open the vi ref.
      It returns the data BUT ... requests are still sequential and not parallel :-(  
      LabVIEWHTTPClient.lvlib:GET.vi blockdiagram is protected with a password, but I assume it still blocks because of a dll call.
      Did anyone make an application with parallel http requests ?
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.