Company Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Building a Web Service (Windows)

LabVIEW 2009 Help

Edition Date: June 2009

Part Number: 371361F-01

»View Product Info

You can build a Web service using the Build Specifications in the Project Explorer window. After you build the Web service, you must deploy the Web service to activate its functionality. Before you create a Web service build specification or start the build process, review the Building Applications Checklist.

You also can step through the tasks for building an example Web service. In the tutorial, you create and interact with a Web service using a simple Web method VI and a Web browser.

Note  LabVIEW Web services are available only in the LabVIEW Full Development System and the LabVIEW Professional Development System.

Complete the following steps to build a Web service.

  1. Activate Web services on a LabVIEW Web Server instance.
  2. Open the LabVIEW project you want to use to build the Web service. You must have a project open and saved to configure a Web service build specification.
  3. Create Web method VIs in the LabVIEW project and prepare them for use in the Web service. Save changes to VIs in memory before you create or edit a Web service.
  4. Right-click Build Specifications and select New»Web Service (RESTful) from the shortcut menu to display the Web Service Properties dialog box. If you previously hid Build Specifications in the Project Explorer window, you must display the item again to access it.
  5. Complete the following items on the Information page of the Web Service Properties dialog box.
    1. Enter a name for the build specification in the Build specification name text box. This name appears under Build Specifications in the Project Explorer window. The name must be unique among other build specification names in the project.
    2. Enter a name for the Web service in the Service name text box. The service name must conform to standard URL syntax, because the service name is part of the URL that HTTP clients use to access the Web service. The Application Builder also uses the service name and automatically appends a .lvws extension when creating the Web service file.
    3. Enter the location for the Web service in the Destination directory text box. You can use the Browse button to navigate to and select a location.
  6. Complete the following items on the Source Files page.
    1. From the Project Files tree, select the VI you want to define as a service VI, or Web method VI, in the Web service. You must define at least one Web method VI in the Web service. You also can select multiple files in the Project Files tree to add several files at one time to the Service VIs or Always Included listbox.
    Note  You cannot include a polymorphic VI or a LabVIEW class in the Service VIs or Always Included listboxes. Use an instance of the polymorphic VI instead.
    1. Click the Add Item arrow button next to the Service VIs listbox to move the selected VI to the Service VIs listbox. The Configure RESTful VI dialog box appears. Use this dialog box to define the parameters of the Web method VI. When you add a Web method VI to the Service VIs listbox, LabVIEW creates a default URL mapping on the URL Mappings page of the Web Service Properties dialog box.

      Define the parameters of the service VI in the Configure RESTful VI dialog box, and then click the OK button to return to the Web Service Properties dialog box.
  7. From the URL Mappings page, configure the URL mapping for the Web service. You also can define the value / as a URL mapping to assign a default Web method VI to the Web service.
  8. From the Service Settings page, configure the Web service to publish to all or some of the available Web Server instances that support Web services. You also can enable default request support or configure service aliases for the Web service.
    • By default the Web service publishes on all available Web servers that support Web services. Select Tools»Options to display the Options dialog box and select Web Server from the Category list to add or configure available Web servers.
    • On the Service Settings page, if you do not select Publish Web service on all Web servers, you can select on which available Web Server instances to deploy the Web service from the Web servers listbox.
    • You can enable default request support to load a default index.html file from the static document folders. An index.html file must be located in the appropriate static document folder within the Web service.
    • You can create service aliases, which define alternate names for the value specified in the Service name component of the Information page. Use service aliases to allow more than one option for the Service name component of a custom browsing URL.
  9. From the Destinations page, configure destination settings and add destination directories to the Web service.
  10. From the Source File Settings page, edit destinations and properties for individual files and folders in the Web service.
Note  If you plan to distribute a Web service that uses shared variables, do not include the .lvlib file in the Web service. Change the Destination of the .lvlib file to a destination outside the Web service.
  1. From the Advanced page, place a checkmark in the Enable debugging checkbox to enable remote debugging of a Web service. This ensures that LabVIEW deploys both the front panel and block diagram for each Web method VI in the Web service.
  2. From the Additional Exclusions page, configure settings to disconnect type definitions, remove unused polymorphic VI instances, and remove unused members of project libraries to reduce the size of the Web service.
  3. From the Preview page, click the Generate Preview button to review the generated files for the Web service.

    Save changes to VIs in memory before you create or edit a build specification to ensure that the preview is accurate.
  4. Click the OK button to update the build specification settings in the project and close the dialog box. The build specification name appears in the project under Build Specifications.

    Creating or updating the build specification does not build the Web service. You must complete the next step to build the Web service.
Note  When you update the build specification settings, the settings become part of the project. However, you must save the project if you want to save the settings.
  1. Right-click the Web service build specification name and select Build from the shortcut menu. You can find the resulting Web service in the directory specified in the Destination path on the Destinations page of the build specification.

    You also can click the Build button in the Web Service Properties dialog box to build the Web service and update the build specification.
  2. After you build the Web service, you must deploy the Web service to activate its functionality.

Right-click the build specification item you want to duplicate and select Duplicate from the shortcut menu to create a copy of the build specification item.

If you rebuild a given specification, LabVIEW overwrites all existing files from the previous build.


 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit