Parent Topic: Sending Data to a Published Application using URLs
|Note For more information about concepts in this topic, refer to the Web services introduction and tutorial. LabVIEW Web services are available only in the LabVIEW Full Development System and the LabVIEW Professional Development System.|
Web clients use URLs to exchange data with published Web services. URL mappings and query strings are parts of the URLs:
For an HTTP method VI named Add.vi, LabVIEW automatically defines the URL mapping as /Add. If the VI contains the inputs a and b, the URL and query string /Add?b=2&a=3 assigns values to the inputs. In this example, the URL a client uses is http://127.0.0.1:8080/WebService/Add?b=2&a=3.
|Note Instead of using default URL mappings, you can customize URL mappings, which affects how you assign values to input parameters of an HTTP method VI.|
A client can omit any input parameters from the query string. If a client omits an input parameter value, the Web service uses the default value for the input terminal stored in the VI. For example, given an HTTP method VI named Add.vi with controls labeled a and b, HTTP requests using the following URL mappings and query strings are valid:
Typically, you can use the default URL mappings for a Web service. However, in advanced use cases, you might want to customize the URL mapping for an HTTP method VI. Complete the following steps to configure a custom URL mapping for an HTTP method VI:
You can configure the URL mapping string as any value as long as the value begins with a forward slash and uses standard HTTP syntax. You can append input parameters to the end of a URL mapping by adding a forward slash, a colon, and the label of a connector pane input in the associated HTTP method VI. Note that this syntax is different from how you append query strings to default URL mappings to set parameter values.
An example of a custom URL mapping string is /Add/:a/:b. The URL mapping string /Add is the base of the URL mapping and /:a/:b configures input parameters for the HTTP method VI. If the URL mapping contains no input parameters to pass to the HTTP method VI, the VI must contain default values for any input terminals.
You can create a custom browsing URL that assigns multiple fragments of the URL to a single string input terminal of the HTTP method VI. This technique is useful for passing file paths or other hierarchical values using a custom browsing URL.
For example, /:x/*y creates an input parameter for a control labeled x and a control labeled y when appended to a URL mapping. You then can append a value, such as /test/C/directory, to the custom browsing URL that corresponds to the input parameter /:x/*y that you added to the URL mapping. In this example, x is assigned test and y is assigned C/directory. The input parameter that contains more than one fragment must occur at the end of the custom browsing URL.