Represents a connection to an XML Web service.
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.
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.