WebServiceConnection Class

Represents a connection to an XML Web service.

Inheritance Hierarchy

System.Object
  Microsoft.Office.InfoPath.DataConnection
    Microsoft.Office.InfoPath.WebServiceConnection

Namespace:  Microsoft.Office.InfoPath
Assembly:  Microsoft.Office.InfoPath (in Microsoft.Office.InfoPath.dll)

Syntax

'Declaration
Public MustInherit Class WebServiceConnection _
    Inherits DataConnection
'Usage
Dim instance As WebServiceConnection
public abstract class WebServiceConnection : DataConnection

Remarks

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.

Examples

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.

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.

string wsServiceURL = wsConnection.ServiceUrl.ToString();
Dim wsServiceURL As String = _
   string wsServiceURL = wsConnection.ServiceUrl.ToString()

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

WebServiceConnection Members

Microsoft.Office.InfoPath Namespace