Consuming Web Services in InfoPath Part 2: Setting Up the Data Connection
Now, we are going to set up data connections for our form. Just in case you do not know why we should use Data Connections, here is an abstract from MSDN about the benefits of using Data Connection
[Source]
Using a UDC file located in a data connection library has the following benefits:
Form designers can configure form template data connections that will work in both the InfoPath client and InfoPath Forms Services.
Form designers can publish a form template to multiple servers and have different data connection settings for each server without modifying the data connection information in the form template.
Form designers can publish a domain security form template that can access data sources in a different domain.
Administrators can redirect data connections without modifying form templates that reference the UDC file.
Administrators can designate which connections are approved for cross-domain access.
Administrators can publish data connections on a single server which can be shared across multiple servers.
[/Source]
To create a data connection,
- Fire up InfoPath 2007 and design a new form
- Click on [Tools] -> [Data Connections]
- Click on [Add]
- Select [Create a new connection to:] and [Receive data]
- Select [Web service]
- Enter the url of your web service
- Select [GetPrice]
- If you want, you can set the default value now.
- At the last screen, give your webservices a name (which I'm calling mine MetalExchange), and uncheck [Automatically retrieve data when form is opened]
- Next, convert your data connection by clicking [Convert]
- Specify the url of a data connection library, and select either one... (I don't think it matters here, since the data connection file is still saved to the data connection library, and not the one in central admin)
- Click on [Ok]
- Click on [Close]