LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write clusters -- WebServer

Solved!
Go to solution

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,

Download All
0 Kudos
Message 1 of 9
(3,708 Views)

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).


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 2 of 9
(3,682 Views)

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!!!

 

 

0 Kudos
Message 3 of 9
(3,675 Views)

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).


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 4 of 9
(3,654 Views)

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!!!!

0 Kudos
Message 5 of 9
(3,642 Views)
Solution
Accepted by topic author juanfer23

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:

2015-03-18_16-58-21.png

 

In the VI, you can read out the POST data using a number of VIs:

2015-03-18_17-00-53.png

 

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:

POST_Snippet.png

 

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>


LabVIEW Champion, CLA, CLED, CTD
(blog)
Message 6 of 9
(3,628 Views)

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!!!

Download All
0 Kudos
Message 7 of 9
(3,612 Views)

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!!!!

0 Kudos
Message 8 of 9
(3,607 Views)

hi,

Can you please share the code.

Thanks in advance.

0 Kudos
Message 9 of 9
(1,572 Views)