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.
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.
11-07-2009 01:06 PM
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?
11-09-2009 11:15 AM
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.
11-10-2009 09:24 AM
11-10-2009 10:26 AM
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?
11-11-2009 11:17 AM
11-11-2009 11:48 AM
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
11-11-2009 02:10 PM
11-13-2009 08:46 AM - edited 11-13-2009 08:47 AM
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.
07-01-2010 02:24 PM
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?
01-11-2011 11:06 AM - edited 01-11-2011 11:09 AM
BCho,
Thank you very much for the very nice explanation of using the document property.
Best regards