03-17-2015 07:18 AM
Hallo,
I´m trying to use a webserve for sharing data.
When I´m using simple variables, or small clusters the system is working without any problem, using JSON for doing the transformation (cluster to string).
The problem is when I need to use a huge quantity of data (big cluster), looks like the input string (when Im trying to write data in the sever) has limitations for that (max length).
Could anybody let me know how should I work in this cases? or any example for that??
Thanks and best regards,
Solved! Go to Solution.
03-18-2015 04:54 AM - edited 03-18-2015 04:55 AM
There probably is some sort of limit on the length of the URL string (as you're using GET). Maybe you could send the data as POST instead (so it doesn't appear in the URL?). Even then, most webservers (I don't know about the LabVIEW one...) have a limit on the size of data you can POST and also generally have a timeout for the transfer of data.
As an aside - I think you might need to URL encode the string when using GET to convert any non-safe characters to their ascii encoded counterparts. I think there are functions for this in LabVIEW (escape http url).
03-18-2015 05:38 AM
Thanks so much Sam,
I was already working with the POST option, but I have doubts about the controlling.
As I cannot change the data variables (cluster) with the URL string, how can I access them? I cannot open the sub.vi (POST) throught the server (Access Error: 404 -- Not Found).
I was taking a look of some examples I could find, and for this, they are using a pre-defined "Index.html" where they are using some controls to actuate in the (POST) sub.vi.....but I dont have too much knowledge about html....is there any other way to control this cluster?
Thanks so much for your help and time!!!
03-18-2015 07:30 AM
How are you interfacing with your web service? From a browser? LabVIEW?
If it's LabVIEW - you can use the HTTP Client VIs.
If it's from a browser, you can either create a form with the action set to your web service URL to POST the form fields to the web service or use javascript to do it via AJAX (so you can post the data asynchronously without having to change the page).
03-18-2015 10:59 AM
Thanks so much Sam,
The idea is to access the web server from a browser, and can also read-write the data in Real Time (Labview), so I would use it like interface.
As you indicated me I have to ways of controlling:
- Using Client VIS.
For this I was creating an extra sub.vi (POST.vi), were I send the data that I want to modify in my sistem.
Im not getting any error in the subvi, but when I update the read.vi (GET) the data didnt change....Did I missunderstand it? (I attached the program Im working with)
- Create a form with the action set to the web service URL. Could you please show me any example?
- Use Javascript (via AJAX)
Thanks a lot for your time!!!!
03-18-2015 12:30 PM
I can't open your project as I don't have LV2014 (I have 2013) but here are some pointers:
Let's say you have a web service method VI as follows:
In the VI, you can read out the POST data using a number of VIs:
These will return the data you POST-ed to the web service URL.
The HTTP Client POST VI will allow you to post either a string of data or key-value pairs to your Web Service:
If you're using a web browser...either use jQuery/AJAX to POST the data (http://api.jquery.com/jquery.ajax/) to the web service URL or create a simple HTML form:
<form action="webserviceurl" method="POST">
<input name="myfield1" type="text" />
<input type="submit" />
</form>
03-19-2015 03:58 AM - edited 03-19-2015 04:04 AM
Hallo Sam,
Thanks so much for your help. Sorry for bothering you again.
In the example im trying to do, i´m following almost the same steps that you explained me.
Only that I am using a cluster and therefore I use the JSON for doing the string conversion.
(I attached again example in LV2013 and a image)
If I access to my web service readvalue.vi (GET) using the corresponding URL in the server, i read the String value of my cluster without errors.
Then, when Im trying to use the HTTP client POST.vi for post new data in my webserver (using String), the subvi looks like working (POST.vi), but I dont see any change in my webserver writevalue.vi(POST) or in my readvalue.vi(GET).
Did I missunderstand the process??
Thanks again for your help and time!!!
03-19-2015 04:23 AM
Hallo Sam,
I already fix it. I was using the incorrect way of reading.
I changed it for "Read Post Data.vi" and everything is working 🙂
Thanks again for yout time!!!!
07-08-2021 01:42 AM
hi,
Can you please share the code.
Thanks in advance.