Partager via


WebServiceConnection.Execute Method (XPathNavigator, XPathNavigator, XPathNavigator)

Overrides the default Execute method inherited from the DataConnection base class to allow specifying a different source of data to submit, a different location to insert the data that is returned, or a location to insert any error text returned.

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

Syntax

'Declaration
Public MustOverride Sub Execute ( _
    input As XPathNavigator, _
    output As XPathNavigator, _
    errors As XPathNavigator _
)
'Usage
Dim instance As WebServiceConnection
Dim input As XPathNavigator
Dim output As XPathNavigator
Dim errors As XPathNavigator

instance.Execute(input, output, errors)
public abstract void Execute(
    XPathNavigator input,
    XPathNavigator output,
    XPathNavigator errors
)

Parameters

  • input
    Type: System.Xml.XPath.XPathNavigator

    An XPathNavigator object that is positioned at the XML node to insert into the <SOAP:Body> element of the Web service. The specified XML node should contain XML corresponding to the full set of query parameters and their corresponding values.

    • For a data connection configured as a query operation, this overrides the declarative setting, which is the query fields (descendents of <dfs:queryFields>) of the associated DataSource object.

    • For a data connection configured as a submit operation, this overrides the complete set of part fragment mappings.

    • If the input parameter is specified as a null reference (Nothing in Visual Basic) then the declarative settings are used.

  • output
    Type: System.Xml.XPath.XPathNavigator

    An XPathNavigator object that is positioned at the XML node under which to insert the contents of the <SOAP:Body> element returned by the Web service.

    • For a data connection configured as query operation, this overrides the declarative setting, which is the data fields (descendents of <dfs:dataFields>) of the associated DataSource object.

    • For a data connection configured as a submit operation, this overrides the complete set of part fragment mappings.

    • If the output parameter is specified as a null reference (Nothing in Visual Basic) for a data connection configured as a query operation, then the declarative settings are used. If the data connection is configured as a submit operation, then the returned data isn't written at all.

  • errors
    Type: System.Xml.XPath.XPathNavigator

    An XPathNavigator object that is positioned at the XML node under which to insert the contents of error text returned in the <Fault> element by the Web service, if the operation fails. If the errors parameter is specified as a null reference (Nothing in Visual Basic), then the error data is not written at all.

Exceptions

Exception Condition
WebException

A network error occurred while attempting to access the Web service.

ArgumentNullException

The parameters passed to this method are a null reference (Nothing in Visual Basic).

ArgumentException

The parameters passed to this method arenot valid. For example, they are of the wrong type or format.

Remarks

When the action of a data connection that a WebServiceConnection object represents is executed, InfoPath wraps the data (as query parameters) in a SOAP envelope and then submits it to the Web service. The data connection then obtains the data returned by the Web service in the SOAP message or, in the case of failure, as error message data. Each data connection that a WebServiceConnection object represents is created in the InfoPath using the Data Connection Wizard as either a query operation or a submit operation.

Data connections defined as query operations are associated with a specific DataSource object from which they receive query parameters (contained within query fields defined in the <dfs:queryFields> node of the form's data source) and into which they insert the returned data (in the data fields defined in the <dfs:dataFields> node of the form's data source).

Data connections defined as submit operation have part fragment mappings established to pull the data for the query parameters from different DataSource subtrees.

The default Execute method inherited from the DataConnection base class uses the declaratively defined input (query parameters) and output location defined using the Data Connection Wizard in InfoPath.

The Execute (XPathNavigator, XPathNavigator, XPathNavigator) method overrides the default version of the Execute method to allow specifying any or all of the parameters described above.

This member can be accessed only by forms running in the same domain as the currently open form, or by forms that have been granted cross-domain permissions.

This type or member can be accessed from code running in forms opened in Microsoft InfoPath Filler or in a Web browser.

Examples

In the following example, three XmlDocument objects are created to work with the Execute method. The first XmlDocument is populated with data, then three XPathNavigator objects are created to pass as the input, output, and errors parameters of the Execute method, and the method is called.

// Open connection.
WebServiceConnection wsc = 
   (WebServiceConnection)this.DataConnections["Main query"];

// Create XmlDocuments.
XmlDocument inputDocument = new XmlDocument();
XmlDocument outputDocument = new XmlDocument();
XmlDocument errorsDocument = new XmlDocument();

// Load input document.
inputDocument.LoadXml("<inputValue1>Test</inputValue1><inputValue2>5</inputValue2>");

// Create XPathNavigator objects for documents.
XPathNavigator inputNav = inputDocument.CreateNavigator();
XPathNavigator outputNav = outputDocument.CreateNavigator();
XPathNavigator errorsNav = errorsDocument.CreateNavigator();

// Call Execute method.
wsc.Execute(inputNav, outputNav, errorsNav);
' Open connection.
Dim wsc As WebServiceConnection = _
   DirectCast(Me.DataConnections["Main query"], WebServiceConnection)

' Create XmlDocuments.
Dim inputDocument As XmlDocument = new XmlDocument()
Dim outputDocument As XmlDocument = new XmlDocument()
Dim errorsDocument As XmlDocument = new XmlDocument()

' Load input document.
inputDocument.LoadXml("<inputValue1>Test</inputValue1><inputValue2>5</inputValue2>")

' Create XPathNavigator objects for documents.
Dim inputNav As XPathNavigator = inputDocument.CreateNavigator()
Dim outputNav As XPathNavigator = outputDocument.CreateNavigator()
Dim errorsNav As XPathNavigator = errorsDocument.CreateNavigator()

' Call Execute method.
wsc.Execute(inputNav, outputNav, errorsNav)

See Also

Reference

WebServiceConnection Class

WebServiceConnection Members

Execute Overload

Microsoft.Office.InfoPath Namespace