Use values from a Web service to populate a list box, drop-down list box, or combo box
You can populate a list box, drop-down list box, or combo box with data from a secondary data connection to a Web service.
In this article
Overview
A list box, drop-down list box, or combo box displays items that a user can select when filling out a form that is based on your form template. You can configure these types of controls to show the data from a secondary data connection to a Web service. A secondary data connection is any data connection to an external data source that you add to a form template so that users filling out forms based on this form template can get data from or submit data to an external data sources, such as a Web service.
To get data from an external data source, you add a secondary data connection to your form template that queries data. As a result, Microsoft Office InfoPath creates a secondary data source with data fields and groups that corresponds to the XML Schema of the Web service. The query data connection gets data from the Web service and stores that data in the secondary data source of the form. By default, the data in the secondary data source is available only while the user is connected to a network. You can configure the secondary data connection to save the results of the query on your users' computers so that they can have access to the data when their forms are not connected to a network.
Security Note: If you are using a secondary data connection to retrieve sensitive data from an external data source, you may want to disable this feature to help protect the data from unauthorized use in case the computer is lost or stolen. If you disable this feature, the data will be available only if the user is connected to the network.
Because the data structure in the secondary data source must match the way that data is stored in the Web service, you cannot modify existing fields or groups in the secondary data source. Find links to more information about data connections and data sources in the See Also section.
Before you begin
Before you can use values from a Web service to populate a control on your form template, you need the following information from the Web service administrator:
-
The location of the Web service.
-
Verification that the Web service uses document/literal style encoding. InfoPath can consume only document/literal style Web services.
-
The name of the Web service operation that will send data to the form.
-
Whether you can safely store the query results from the Web service on the users' computers for offline use.
Step 1: Add a query data connection
If you do not have an existing query data connection in your form template that you can use to supply the values for the control, follow these steps to add a new secondary data connection. If your form template already has a secondary data connection that you can use, you can skip this section and go to Step 2: Configure the control.
-
On the Tools menu, click Data Connections.
-
In the Data Connections dialog box, click Add.
-
In the Data Connection Wizard, click Create a new connection to, click Receive data, and then click Next.
-
On the next page of the wizard, click Web service, and then click Next.
-
On the next page of the wizard, type the location of the Web service.
Note: If you want to search for a Web service by using a Universal Description Discovery and Integration (UDDI) server, click Search UDDI, enter the URL of the UDDI server that you want to search, specify whether you want to search by provider or by a service that is provided, enter a search keyword, and then click Search. Web services that match your search keyword will appear in the Search result list. Select the Web service that you want to use, and then click OK.
-
Click Next.
-
In the Select an operation list, click the Web service operation that returns data to the form, and then click Next.
-
If the Data Connection Wizard encounters an unknown element in the schema of the Web service, the next page of the wizard may ask you to specify sample values for each parameter to determine what fields or groups to add to the main data source.
How?
-
Select a parameter in the Parameters table, and then click Set Sample Value.
-
In the Sample value box, type a value that your user might use for this field, and then click OK.
-
Repeat these steps for each parameter in the Parameters table, and then click Next.
Technical details
When you configure a data connection to a Web service in the Data Connection Wizard, Microsoft Office InfoPath connects to the Web service and requests the Web Service Description Language (WSDL) file. The WSDL file contains the schema used by the Web service. The Web service responds to the request by sending this file to InfoPath. InfoPath uses the information in this file to add the appropriate fields and groups to the secondary data source in the form template. If InfoPath finds an unknown element type in the WSDL file, InfoPath uses sample data to determine the definition of the unknown element type and then adds the appropriate fields and groups to the secondary data source.
-
-
If you want the results of the query to be available when the form is not connected to a network, select the Store a copy of the data in the form template check box.
Security Note: Selecting this check box stores the data on the user's computer when the form uses this data connection. If you are getting sensitive data from this data connection, you may want to disable this feature to help protect the data in case the computer is lost or stolen.
-
Click Next.
-
On the next page of the wizard, type a descriptive name for this secondary data connection.
-
To have the form automatically receive data when it is opened, select the Automatically retrieve data when form is opened check box.
Step 2: Configure the control
-
If the form template has multiple views, click View name on the View menu to go to the view with the control where you want to display the data from the secondary data source.
-
Double-click the list box, drop-down list box, or combo box that you want to populate.
-
Click the Data tab.
-
Under List box entries, click Look up values from an external data source.
-
In the Data Source list, click the data source with the group or fields containing the data that you want to use.
-
Click Select XPath next to the Entries box.
-
In the Select a Field or Group dialog box, specify what data will be shown to the user and what data will be submitted to the external data source by doing one of the following.
Specify that the data the user will see is the same data that the user will submit
-
Click a field, and then click OK.
Specify that the data the user will see is different from the data that the user will submit
Note: In this scenario, the data that the user will see is from one of the fields in the group, and the data that the user will submit is in another field in the same group.
-
Click a group, and then click OK.
-
In the Control Properties dialog box, click Select XPath next to the Value box.
-
In the Select a Field or Group dialog box, click a field that contains the data that the user will submit to the external data source, and then click OK.
-
In the Control Properties dialog box, click Select XPath next to the Display name box.
-
In the Select a Field or Group dialog box, click a field that contains the data that will appear in the control, and then click OK.
-
-
If the field in the Display name box has values with similar display names and you want to display only unique names, select the Show only entries with unique display names check box.
No comments:
Post a Comment