When you build a Web service, you can integrate static content such as HTML files, JavaScript files, CSS files, images, and videos from within the LabVIEW project. For example, you can publish stand-alone web pages using Web services or provide a user interface that interacts with the HTTP method VIs in a Web service.
Complete the following steps to integrate static content into a Web service:
Organize static content on disk in two main folders: one that contains public content and one that contains private content you do not want to expose to users.
Open the LabVIEW project that contains the Web service files.
Right-click the Web service project item in the project tree and select Add Public Content Folder or Add Private Content Folder.
In the browse dialog box that appears, select the folder on disk that contains files you want to include in the Web service.
LabVIEW creates an auto-populating folder named Public Content or Private Content under the Web service project item. Any files in the folder on disk appear under the folder that you added to the project tree.
The following project shows a project that contains a Public Content folder. The corresponding folder on disk contains the same files and subfolder as in the project tree.
After you publish the Web service, you can access the static files from a client, such as a web browser, by navigating to the URL mapping for the file you want to access.
Finding the URL Mapping for a Public File
LabVIEW automatically assigns a URL mapping to each public static file. You cannot change this mapping. Complete one of the following steps to view the URL mapping for a public static file:
For a specific static file or folder, right-click the file in the project tree and select Show Public URL.
To view URL mappings for all public static files and folders, right-click the Web service project item and select Properties to display the Web Service Properties dialog box. On the Site Map page, the table contains a row with the URL mapping for each public static file and folder.
Integrating Default HTML Files
You can include an index.html file within each public content folder and subfolder in the project. When a client sends an HTTP request using a URL such as http://localhost/TutorialService/, the Web service returns the index.html file.
Complete the following steps to integrate a default index.html file for a specific public content folder:
On disk, add a file named index.html to a folder that appears under the Public Content folder in the project. In the previous example, you place the file in the folder on disk that you associated with the top-level Public Content folder. The file automatically appears in the project tree unless you stop the folder from auto-populating changes in the corresponding folder on disk.
Note The file extension must be .html.
Right-click the Web service project item and select Properties.
On the Service Settings page, place a checkmark in the Serve default index.html for public folders checkbox, and click OK.
In a Web browser, navigate to the URL that corresponds to the folder with the index.html file. The HTML file loads in the browser.
Integrating Private Content in Web Services
Private static files do not have URL mappings because web clients cannot access private content. To programmatically access private static content within Web service source files, use the Read Service Attribute VI to return the path to the folder that contains private content at run time. With the path to the private content folder, you can build a path to a specific file. Refer to the Read Service Attribute VI help for more information.