Parent Topic: Building a LabVIEW Application to Deploy Remotely
When you build a Web service, you can integrate static content such as HTML files, stylesheets, images, movies, and JavaScripts from within the LabVIEW project. You can use static content to publish stand-alone Web pages using Web services or to provide a user interface that interacts with the Web method VIs in the Web service.
 |
Note LabVIEW Web services are available only in the LabVIEW Full Development System and the LabVIEW Professional Development System. |
Complete the following steps to integrate static content into an existing Web service. You also can add static content to a new Web service by completing these steps during the initial configuration of a Web service.
- Open the LabVIEW project that you are using to build the Web service. You must have a project open and saved to configure a Web service build specification.
- Add a folder of static content, such as a folder of images, to the Project Explorer window. For example, add a folder named images that contains two images named example1.gif and example2.gif.
- Double-click an existing Web service build specification to display the Web Service Properties dialog box.
- From the Category list on the left, select the Source Files page.
- From the Project Files tree, select a folder containing static files you want to include in the Web service, such as the images folder.
- Click the Add Item arrow button next to the Always Included list to move the selected folder containing static files to the Always Included list.
- From the Category list on the left, select the URL Mappings page to specify URL mappings that allow clients to access the static content.
- Click the Add URL Mapping plus button next to the URL mappings list.
- Enter a value to correspond to a folder containing static content, for example, /images.
- Select the Static document option for the URL mapping under the Type category.
- From the Category list on the left, select the Destinations page to configure destination settings for the static content.
- Click the Add Destination plus button below the Destinations list.
- Enter a destination label, for example, images.
- From the Category list on the left, select the Source File Settings page to associate a destination with the specific static content files.
- Select a folder containing static files, such as the images folder, from the Project Files tree.
- Place a checkmark in the Set destination for all contained items checkbox.
- From the Destination pull-down menu, select the corresponding destination. The item selected must match the destination you created on the Destinations page, for example, images.
- Click the Build button in the Web Service Properties dialog box to build the Web service and update the build specification.
- After you build the Web service, you must deploy the Web service to activate its functionality.
From a client, such as a Web browser, access the static files by navigating to the URL that corresponds to the URL mapping including the filename of the static content you want to access. For example, http://localhost/WebService/images/example1.gif.
Adding a folder containing static files allows you to configure a single URL mapping that corresponds to multiple files. You also can add individual static files not contained within a folder to a Web service, but you must configure a URL mapping for each file. For static files not contained within folders, the value of the URL mapping must match both the destination that you configure on the Destinations page and the destination that you select from the Destination pull-down menu on the Source File Settings page.
You also can specify a default index.html file within each static folder. In order to enable a default index.html file, you must include the file within the static folder in your LabVIEW project. On the Service Settings page, place a checkmark in the Serve default index.html for static document folders checkbox. An index.html file within the images folder in this example would appear using the custom browsing URL http://localhost/WebService/images/.