LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Limiting plot by timestamp from a SQL DB using POST method - LV 2016 & NXG 3.0

Solved!
Go to solution

Hello guys,

I am trying to update a chart limiting by timestamp. I am sending a SQL string from my webvi to my webserver.

The string is correct, i tested isolated, but when I sent from my webvi to my webser I get the following errors.

 

history_post-vi.jpgerror_nxg.jpgI also attached my vis to help finding any solution  

0 Kudos
Message 1 of 6
(2,909 Views)

Hi Granado_93,

 

I think the issue may be similar to one we discussed before in the LabVIEW 2016 Web Server and web page with Labview NXG 3.0 post. In the example provided it looks like the Historico.vi needs to be marked as Streaming and to enable Use headers and Buffered.

 

streamingresponse.PNG

 

One thing to point out is that it can be dangerous to accept and run SQL statements from a web page. A WebVI running in a webpage on your computer is no different than any other web page you visit in a web browser. It is possible for a malicious web page to send an SQL statement to your LabVIEW Web Service that can do unexpected operations.

 

Some best practices are to not send SQL queries from your WebVI to the Web Service but instead send specific parameters that you sanitize on the LabVIEW Web Service. For example in this case your SQL query has two timestamps as parameters. Instead of building the sql query in the WebVI and sending it to the LabVIEW Web Service you can send the two timestamps, parse them to make sure they are valid timestamps, and build / run the SQL query in the LabVIEW Web Service.


Milan
Message 2 of 6
(2,888 Views)

Hi MilanR

 

I changed the output type to stream as you told. But it did not work yet. I have the same error that I had in the previous exemple.

NGX still complains that CORS is not presented on the request source, even though I had the CORS block on my web server.

Am I missing something else?

regards

0 Kudos
Message 3 of 6
(2,874 Views)

Hello MilanR,

 

I did the modifications as follows historico_nxg.PNGhistorico_vi.PNGBut still, I got the same error about CORS.

 

I tested and my web server don't receive nothing from my webvi.

0 Kudos
Message 4 of 6
(2,870 Views)
Solution
Accepted by topic author Granado_93

Hi Granado_93,

 

Looking at the Historico.vi Web Resource more closely I see two issues. The first is that the Historico.vi is configured to respond to GET requests but the WebVI is sending a POST request. If the Historico.vi should respond to the WebVI as is then it should be changed to respond to POST requests.

 

The second issue is that the Historico.vi does not have the LabVIEW Web Service Request control connected to the connector pane. You have to have the class reference connected to the connector pane to be used by the LabVIEW Web Service.


Milan
Message 5 of 6
(2,860 Views)

Hi MilanR

It should be POST, I think I changed to test something else.

 

BUt you were right about the LabVIEW Web Service Request control. I connected the control to the connector pane and send two string as timestamp and it works as I wish it.

 

Thank you for your help!

 

0 Kudos
Message 6 of 6
(2,858 Views)