|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
WebServiceConnection Class (Microsoft.Office.InfoPath)
Assembly: Microsoft.Office.InfoPath (in microsoft.office.infopath.dll)
The WebServiceConnection class represents a data connection created in InfoPath using the Data Connection Wizard that specifies all the information necessary for retrieving data from and submitting data to an external data source using a Web service.
The WebServiceConnection provides properties that can be used to get and set information about the data connection's input and operation strings. It also provides a property for getting the Uniform Resource Locator (URL) of the Web Services Description Language (WSDL) file of the XML Web service.
The WebServiceConnection object associated with the data connection is accessible using the DataConnections property of the XmlForm class to return the connection from the DataConnectionCollection of the form template.
In addition to the default Execute method inherited from the DataConnection base class that performs a query or submit operation using the values that were declaratively defined in InfoPath form template design mode, the WebServiceConnection class also provides the WebServiceConnection.Execute method, which allows you to specify a different source of data to submit, a different location to insert the returned data, and a way to retrieve errors returned by the connection.
The WebServiceConnection class corresponds to the WebServiceAdapterObject interface of the Microsoft Office InfoPath 2003 object model.
In the following example, a reference to the WebServiceConnection object that represents the connection named "Main query" is set by passing the name to the Item property of the DataConnectionCollection class, and then casting the returned object to the WebServiceConnection type.[C#]
WebServiceConnection wsConnection = (WebServiceConnection)this.DataConnections["Main query"];
Dim wsConnection As WebServiceConnection = _ DirectCast(Me.DataConnections("Main query"), WebServiceConnection)
After the reference has been set, you can use the properties of the WebServiceConnection object as shown in the following example, which sets a string variable to the value returned by the ServiceUrl property.