You can help by commenting or suggesting your edit directly into the transcript. We'll review any changes before posting them. All comments are completely anonymous. For any comments that need a reply, consider emailing training@inductiveautomation.com.
Version:
LESSON LIST
-
6:41Tag Binding
-
4:55Indirect Tag Binding
-
3:16Property Binding
-
3:27Expression Binding
-
4:55Query Binding
-
5:35Tag History Binding
-
2:43Component Overlays
Take Topic Challenge
Supplemental Videos
-
3:31HTTP Binding
-
2:55Expression Structure Binding
-
3:14Tag Binding - Expression
-
3:01Tag History Binding - Expression
-
2:55Tag Drop
LESSON
HTTP Binding
Description
Learn how to use an HTTP binding to fetch Internet resources in different Perspective settings.
Video recorded using: Ignition 8.0
Resources
Transcript
(open in window)[00:00] Perspective allows us to integrate network and internet driven resources seamlessly into our project. To this end, Perspective offers a special binding type called an HTTP Binding. This is an advanced binding type suitable for those familiar with web-development and HTTP. That said, the binding streamlines fetching of resources from network and internet locations. To demonstrate, I have a label here and on this label I'd like to show an HTML string that I derive from an internet source. So to demonstrate, I'm going to bind the text property of my Label, and I'm going to select an HTTP binding. From here, we can configure every aspect of our HTTP request So for starters, I can specify the target URL and actually, our URL is an expression so I can open up the Expression Editor here. I already have a static URL that I'd like to use so I'm just going to paste it in. And I'm going to click OK. Note that the quotation marks around the URL are required as this is a full-fledged expression. Now I can select the HTTP method I'd like to use. All HTTP methods are available, I'm just going to choose GET, I don't need to configure any headers for our request but if I did, I would click the plus icon here and if I click within the Key field, I can select a dropdown which will show all of the standard headers for our request I can also enter my own header and my Value again can be an expression. I don't need it right now so I'm just going to click the remove icon. I can also configure a body for our request again, an expression. And if the URL requires any authentication maybe it's an API, we can select an authentication type and enter the string for the authentication value that we need, I don't need any authentication right now. From here, we can also modify the timeouts for our requests. And finally, in addition to the standard binding options like Enabled and Overlay Opt-Out we have the option to allow or disallow Cookies from the URL and we can specify a Polling rate, I'll simply leave Polling off for now and that's all it takes, I can click OK now and text on the label has been populated with an HTML document from the URL. Now in this example, we're fetching HTML which we receive as a string. I'd like to use a different URL, one that will give us an object in JSON format. Since Perspective components also use JSON format, this will allow us to fetch JSON documents as Perspective component properties. So to demonstrate, on the root container of our View, I'd like to add a custom property. And I'd like it to be an Object, let's call this object "response" And now I'm going to configure another HTTP binding on the new custom property. Now I'll leave all of our settings the same as before I'll paste in the same URL, but this time I'm going to change it. So we're going to get a different page, this page that I'm using happens to be configured to return a JSON object. That's all it takes to configure, I'm going to leave everything else the same and I'm just going to click OK and now you can see that the response object in our custom properties has been populated with data from the URL.