Create the following diagram to retrieve data from a web service and display that data on the panel.
|If you want your web application to run continuously in a web browser, place your code in a While Loop with a False constant wired to the condition terminal. Otherwise, your web application runs only once in the web browser.|
|Place the code that calls the web service within a Case Structure. The Case Structure prevents the GET node from making a request to the web service in each iteration of the While Loop. Making a GET request each time the While Loop iterates is unnecessary because the data you're accessing probably doesn't change as quickly as the loop iterates. Most web services also limit how many requests you can make per second and may even ban your IP address if you make too many requests.|
|Enter the URL of the web service that you want to call. You can replace this code with a string constant containing the URL of a web service. You can also create code that programmatically creates a URL based on user input. In this example, Minimum Magnitude and Number of Earthquakes to Display determine what values make up the URL.|
|The GET node sends a request to the web service and returns data from that web service. In this example, the GET node sends a request to the U.S. Geological Survey web service and returns the latest earthquake data.|
|Create a subWebVI that parses the data that the web service returns. The web service in this example returns data in the JSON format, which is what most web services return. Other common data formats are XML, CSV, and YML. If a web service returns data in a format other than JSON, you can use other String nodes to parse that data.|
|To reduce load and improve performance when you run your built web application on a web browser, add a Wait node to any WebVI that uses an infinite While Loop.|
If the GET node doesn't return any data or returns unexpected data, verify the following conditions:
If each of these conditions is true, try one of the following:
Refer to the W3C website for more information about HTTP status codes and headers.