Considerations When Accessing Data from Web Services
- Updated2022-01-06
- 1 minute(s) read
Considerations When Accessing Data from Web Services
If you want to create a web application that sends requests to and receives responses from a web service, you need to know the origin of the web service that hosts the web application as well as the origin of the target web service.
For example, a web application hosted at http://localhost:8080/Demo/MyExample.html has the origin http://localhost:8080. A server origin contains three parts:
| Part | Definition | Example |
|---|---|---|
| Scheme | Protocol the web service uses. | http:// |
| Host | Domain name or IP address of the service. | localhost |
| Port | TCP port of the web service. If you don't specify a port, the web service uses the default port. | 8080 |
Once you know the origin of the host web service and the target web service, determine whether requests from the web application to the target web service will be same-origin requests or cross-origin requests. If both origins are identical, requests from the web application to the web service are same-origin requests. If there is any difference between the two origins, requests from the web application to the web service are cross-origin requests.
Browsers running web applications do not impose restrictions on same-origin requests. Web applications that perform cross-origin requests are subject to the Cross-Origin Resource Sharing (CORS) mechanism. By default, a web browser blocks all cross-origin requests made to a target web service that is not configured to support CORS.
Related Information
- Types of Cross-Origin HTTP Requests
Cross-origin HTTP requests, either simple or non-simple, determine whether the browser asks the target web service before sending a request.
- Enabling CORS for a Web Service
To incorporate resources from a different origin into your web application, configure CORS for the server hosting those resources.
- Configuring CORS for a LabVIEW Web Service
You may need different CORS configurations for each LabVIEW Web Service in your application during development and deployment.
- Sending a Credentialed Cross-Origin HTTP Request
Enable credentials in your WebVI, such as including and storing HTTP cookies, adding HTTP Authorization headers, or permitting TLS client certificates to interact with a web service.
- Hosting a Web Application During Development
Host WebVIs running in the G Web Development Software editor with NI Web Server or the G Web Development Software embedded web server.