From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

ActiveX and IE using https and TLSv1

I'm starting with the ActiveX - Internet Explorer example found in C:\Program Files\National Instruments\LabVIEW 2009\examples\comm\ axevent.llb.  In the Navigate2::URL parameter, I can type in the IP address of a device I'm trying to talk to and it will serve up some web pages.  In the WebBrowser in the front panel, I can see the pages, fill in form data and send it, and get stuff back (in the form of more html pages).  My problem is that I need to automate this interface, and in the final app, the server is going to send me XML, and not html.  So, what I want to do is to perform GET/POST commands, capture the data, parse/analyze the XML, repeat.  Also, this is all done in secure mode.  In the example above, I can type in https://xx.xx.xx.xx and after the login, I'm in.  I see the opening (secure) page in the webBrowser on the front panel.  What I need is

(1) to understand how to send in more specific commands.  Right now, after I type in the initial https link, my labview code really isn't doing anything.  It's all in the front panel's webBrowser.  I need to be able to send in specific GET commands, like GET https://xx.xx.xx.xx/setupRfData.asp HTTP/1.1.  And specific POST commands like POST https://xx.xx.xx.xx/setupRfData.cgi HTTP/1.1.  What I'm not sure about is how to pass in those parameters to the ActiveX Navigate(2) command.  I see the API at

 

http://msdn.microsoft.com/en-us/library/aa752093(VS.85).aspx

 

but it's not really clear how use it with LabVIEW.

 

(2) In the POST commands, I have to send in data, which I assume goes in the POSTdata field, but the format is unclear.

 

(3) And the Headers field also is where I'd like to specify certain things like "Connection::Keep-Alive"

 

(4) Finally, this may not have been clear above, but I need to send this device http commands, and it can send me either html or XML based on an input parameter I provide when I send it commands.  If I say "html" then I would just control the device via the web pages it sends back to me.  When it sends back XML, however, instead of a webBrowser, I could probably just have the XML displayed in an edit box?  My concern, though, is that the WebBrowser is what is taking care of all the secure handshaking for me.  How do I keep the link established and still receive/analyze XML?

0 Kudos
Message 1 of 10
(4,958 Views)

Hey mrbean,

 

The resource that you pointed out that outlines the Navigate(2) method for ActiveX control of Internet Explorer is going to be the best resource for details on properties, methods, and events with this ActiveX control. The manner in which you would implement them would be the same in LabVIEW as they would be in any other programming enviornment.

 

In regards to the POSTData function that is part of the Navigate(2) method, I would think that you would put your command in a string and connect it to the POSTData terminal of the ActiveX invoke node. I would guess that it would be the same for the header information that you are looking to send as well.

 

You might also want to check out some of LabVIEW's TCP/IP functionality for this particular task. Check out this HTTP Protocols Example for how you might use HTTP POST and HTTP GET methods using the TCP/IP functionality of LabVIEW. Also, check out this Tutorial.

Hope this helps.
-Ben

WaterlooLabs
0 Kudos
Message 2 of 10
(4,930 Views)
I have one basic question, then one hundred specific ones (I'll ask those later).  (1) How is it that (in the ActiveX - Internet Explorer example found in C:\Program Files\National Instruments\LabVIEW 2009\examples\comm\ axevent.llb) the WebBrowser, on the front panel shows live web data when I'm not even running the VI?  (2) Where does it determine the web page to display in this mode (when I haven't run the VI yet)?
0 Kudos
Message 3 of 10
(4,913 Views)

When using the Navigate2 (activeX WebBrowser command), if I type in (for the URL) https://10.4.17.1/ lets say, I see the desired web page.  What I am not sure how to do is to specify specific GET/POST commands. Does anyone have any examples with Navigate2.  I can manually construct the http commands in one big string and send it using the LabVIEW TCP/IP write command, but this is very tedious and error prone, and it doesn't work in secure (https) mode.  So, where I would previously do a GET /setupRfData.asp HTTP/1.1 or a POST /setupRfData.cgi HTTP/1.1, I am not sure how to tell the URL field of the Navigate2 how to do this.  What I thought I read was that if I wire anything to the PostData input, it is assumed I'm doing a POST, otherwise I'm doing a GET (I assume).  This may not be a good assumption, though, as there are several other http commands (PUT, DELETE, TRACE, CONNECT, etc) that I could theoretically send (although I'm not sure that Navigate2 lets me send anything other than GET/POST).  Anyway, how do I specify the /setupRfData.cgi part of the command, and is HTTP/1.1 assumed?

0 Kudos
Message 4 of 10
(4,909 Views)
Hey mrbean,

To address your first question; the web page continues to update even though the VI may not be running because
when you did run the VI you loaded the script for that page. This script continues to loop even though the VI
is not running. With an IE ActiveX container, it is a lot like you have a normal IE page open; it just happens
to also be a part of your front panel. If you negative, say, www.ni.com, you will notice that even though
the page is fully loaded and IE is not still attempting to load the page, it still 'updates'. You may also notice
that links still work, even though the VI is not still running. So, one way to think about and IE ActiveX
container is like a normal IE window that happens to also be in your VI.

In regards to how to send specific GET and POST commands; unfortunately, I am not very familiar with the ins and
outs of that particular ActiveX control. Judging by the msdn page that you pointed out, I would make the same
assumptions about GET and POST transactions. If you don't wire anything to the POSTData input you do a GET
transaction.

What happens if you send the entire URL https://10.4.17.1/setupRfData.axp HTTP/1.1? If you were
to do this same routine in a normal IE window, what URL would you use? What happens if you do include the HTTP/1.1? How about if you include it, do you get a different response? Here is a Thread that gives a little bit of relevant information.
Hope this helps.
-Ben

WaterlooLabs
0 Kudos
Message 5 of 10
(4,897 Views)

BCho wrote:
Hey mrbean,

To address your first question; the web page continues to update even though the VI may not be running because
when you did run the VI you loaded the script for that page. This script continues to loop even though the VI
is not running. With an IE ActiveX container, it is a lot like you have a normal IE page open; it just happens
to also be a part of your front panel. If you negative, say, www.ni.com, you will notice that even though
the page is fully loaded and IE is not still attempting to load the page, it still 'updates'. You may also notice
that links still work, even though the VI is not still running. So, one way to think about and IE ActiveX
container is like a normal IE window that happens to also be in your VI.

In regards to how to send specific GET and POST commands; unfortunately, I am not very familiar with the ins and
outs of that particular ActiveX control. Judging by the msdn page that you pointed out, I would make the same
assumptions about GET and POST transactions. If you don't wire anything to the POSTData input you do a GET
transaction.

What happens if you send the entire URL https://10.4.17.1/setupRfData.axp HTTP/1.1? If you were
to do this same routine in a normal IE window, what URL would you use? What happens if you do include the HTTP/1.1? How about if you include it, do you get a different response? Here is a Thread that gives a little bit of relevant information.

When I type in the entire URL above, I get a message saying "The Web page you are viewing is trying to close the window (yes/no)".  I've read several forums about this, but most make mention of java script updates and IE7.  I'm using IE6 and I'm not doing any scripting.  I did see another post that said that it's possible I need to specify the "Referer", so I'm going to try that shortly by adding it to the Headers input of the Navigate2.

 

My underlying problem is that the in the current app, the user (me right now) only sees the html pages that the server is serving up (via https/TLSv1).  With that interface, you can enter info into various fields and send them to the server, or click a different tab which behind the scenes performs a GET, but no one has to type any of that.  In our app, we're trying to replace the IE with a labVIEW ActiveX IE and manually build/send these commands so that we can create automated sequences for a production test.  Therefore, I've used a sniffer (WireShark) and have determined what commands/fields are going across the ethernet to the server (and coming back). 

 

As I mentioned, I tried sending the fully qualified GET message ( URL https://10.4.17.1/setupRfData.axp HTTP/1.1) and saw the ...trying to close message.  Assuming I can get past this, my next issue is accessing the response information coming back from the server.  Right now it's html, but in the final product it's going to be XML.  (1) What is the LabVIEW Invoke Method that allows me access to the response information and (2) Is there a way to setup an Event that would notify me when a response came in.  (3) Can the same WebBrowser that currently displays html be used to display XML

0 Kudos
Message 6 of 10
(4,894 Views)
I had some success.  I was able to do a GET by just sending https://10.4.17.1/setupRfData.asp and similarly a POST.  I supplied the Post-Data and it seemed to work.  Now I need to figure out how to retrieve the content out of the html/xml.  Any help with that would be appreciated.
0 Kudos
Message 7 of 10
(4,882 Views)

Hey mrbean,

 

Its good to see that you had a little bit of success with the GET and POST commands. To get the HTML behind the web page, you have to use the WebBrowser2's "Document" property. This is going to be returned in LabVIEW as a variant. Then, you need to use the Variant to Data.vi to convert this document reference to a refnum. The type terminal of the Variant to Data.vi is going to be an Automation Refnum. To get this, you will need to put an Automation Refnum control on your front panel; then, you need to right click and "Select ActiveX Class" and navigate to Microsoft HTML Object Library Version 4.0»DispHTMLDocument. The output of the Variant to Data.vi with then be a Refnum to the document object. To get the body of the HTML page, then you will want to wire this document object reference to an ActiveX property node and select the "body' property. This too is another reference, so you will want to wire this to another ActiveX property node and select the "outerHTML" property. This will give you the HTML behind the web page you are viewing.

 

To get more information about the outerHTML property or the other properties available to you in the WebBrowser, Document, or body classes, you may want to browse through the msdn page you mentioned in your first post. As this ActiveX control is to control am IE web browser, all the properties and methods with the classes mentioned here are outlined on that msdn page.

 

Message Edited by BCho on 11-13-2009 08:47 AM
Hope this helps.
-Ben

WaterlooLabs
Message 8 of 10
(4,854 Views)

The response to one of my questions was this

 

   To address your first question; the web page continues to update even though the VI may not be running because
   when you did run the VI you loaded the script for that page. This script continues to loop even though the VI
   is not running. With an IE ActiveX container, it is a lot like you have a normal IE page open; it just happens
   to also be a part of your front panel. If you negative, say, www.ni.com, you will notice that even though
   the page is fully loaded and IE is not still attempting to load the page, it still 'updates'. You may also notice
   that links still work, even though the VI is not still running. So, one way to think about and IE ActiveX
   container is like a normal IE window that happens to also be in your VI.

 

I understand that the VI loaded, and is running, a script.  My problem is that when I build the executable containing this webBrowser, when we run the EXE on the taget (not the same machine where it was built), it comes up trying to connect to the last place I (the developer) was logged into.

 

Attached are a couple of PNGs that illustrate (1) what I tried to do to correct the problem, but it doesn't work because the webBrowser is already running and (2) the popup that I get before the EXE is hardly even started.  Do I  just need to set the URL to espn.com (for example) when I run the EXE on the development PC, then do my build?  Or, is there a method/poperty (like in my snippet where I try to set the URL property at runtime) where I set the script?

Download All
0 Kudos
Message 9 of 10
(4,483 Views)

BCho,

Thank you very much for the very nice explanation of using the document property.

Best regards

0 Kudos
Message 10 of 10
(4,303 Views)