LabVIEW Web UI Builder Help
Edition Date: October 2010
Part Number: 373286A-01
»View Product Info
To create a VI that communicates with a Web service, you first must tell the LabVIEW Web UI Builder how that Web service sends and receives data, e.g., the signature of the inputs and outputs of the Web service. To give the Web UI Builder this information, just specify the location of the Web service host. The Web UI Builder then generates a strictly-typed API that is specific to that Web service. You use this API on the block diagram to ensure that you send data to, and receive data from, the Web service in the manner it expects.
 | Note If you use a Web service API in a loop, the VI pings the Web service as fast as possible. This behavior can slow down the Web service host as it deals with multiple requests per second, especially if multiple users run the VI simultaneously as a thin-client application.
To address this issue, National Instruments recommends placing a Wait (ms) function inside any loop that calls a Web service. This function is available by selecting Timing»Wait (ms) in the Palette pane. Control the execution speed of the loop by wiring a value, such as 500 or 1000, to the milliseconds to wait input of this function.
|
Before you generate this API, the Web service must meet the following requirements:
- The Web service must have been built and deployed using LabVIEW 2009 or later.
- Each Web method VI you want to connect to must use the Terminal output type and have an Output format of XML. You specify these settings in the Configure RESTful VI dialog box as you create the Web service build specification.
- The Web service must be running. You can test whether a Web service is running by entering its URL in a Web browser. If the Web service is running, the Web browser displays data from this Web service.
- The Web service host must have a valid and well-formed clientaccesspolicy.xml in the root directory. Refer to this topic for information about the clientaccesspolicy.xml file.
- (Browser Version) You must specify http://*.niwsc.com and https://*.niwsc.com in the domain tag of the clientaccesspolicy.xml file. If the *.niwsc.com domain is not specified in the client access policy file, the Web UI builder cannot connect to the Web service to generate an API.
After you ensure the Web service meets these requirements, complete the following steps to generate an API for the Web service.
- On the Project tab of the ribbon, click Import Web Service.
The Web UI Builder displays the Import Web Service dialog box.
- Enter the IP address of the Web service host in the Server Address text box and click the Connect button. The Web UI Builder queries the Web service host. If the connection is successful, the page enables the Web Service drop-down list. This drop-down list contains a list of all the Web services running on the Web service host. If the connection is not successful, the page displays an error message.
- Select the appropriate Web service from the Web Service drop-down list and click the Import button. The Web UI Builder generates the necessary VIs to call this Web service from the block diagram of the editor. These VIs appear in the Project pane under the name of the Web service.
- Display the block diagram of the VI.
- Drag Web service VIs to the block diagram and wire the terminals as appropriate.
This process also generates a Web service library file (.wslib). National Instruments recommends you save the Web service library. You can update the VIs the Web UI Builder generates to reference the Web service library by double-clicking the Web service library item in the Project pane and clicking the Update Library button in the tab that appears.