WebServiceAdapter2.Operation property

Gets or sets the XML string ('outer XML') corresponding to the operation element contained in the form definition (.xsf) file for the WebServiceAdapterObject object.

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

Syntax

'Declaration
Property Operation As String
    Get
    Set
'Usage
Dim instance As WebServiceAdapter2
Dim value As String

value = instance.Operation

instance.Operation = value
string Operation { get; set; }

Property value

Type: System.String

Implements

WebServiceAdapter.Operation

Remarks

The operation element of the .xsf file contains information about the Web service, including the name of the Web method, the method used for retrieving and submitting data, and its Uniform Resource Locator (URL).

Examples

In the following example, the Operation property of the WebServiceAdapterObject object is used to retrieve the properties of the operation element in the .xsf file. The serviceUrl of the WebServiceAdapter is updated, and then the Query method of the WebServiceAdapter is invoked:

const string newServiceUrl = "NewOperationName";

// Get the Main Data Source WebServiceAdapter object
WebServiceAdapter2 webServiceAdapter = thisXDocument.DataAdapters[0] as WebServiceAdapter2;
if (webServiceAdapter == null)
{
 thisXDocument.UI.Alert("A secondary WebServiceAdapter does not exist.");
 return;
}

// Load the xsf:input element into an XML DOM
IXMLDOMDocument2 tempDom = thisXDocument.CreateDOM() as IXMLDOMDocument2;
if (tempDom == null)
{
 thisXDocument.UI.Alert("Could not create a temporary DOM.");
 return;
}
tempDom.validateOnParse = false;
tempDom.preserveWhiteSpace = false;
tempDom.loadXML(webServiceAdapter.Operation);

// All available properties on the operation element: name, soapAction, serviceUrl
IXMLDOMNode nameAttribute = 
 tempDom.documentElement.attributes.getNamedItem("name");
IXMLDOMNode soapActionAttribute =
 tempDom.documentElement.attributes.getNamedItem("soapAction");
IXMLDOMNode serviceUrlAttribute =
 tempDom.documentElement.attributes.getNamedItem("serviceUrl");

// Show the serviceUrl attribute value of the xsf:operation element before the change
thisXDocument.UI.Alert(serviceUrlAttribute.text);

// Change the serviceUrl
serviceUrlAttribute.text = newServiceUrl;

// Show the serviceUrl after the change
thisXDocument.UI.Alert(serviceUrlAttribute.text);

// Save the changes from the tempDom back to the Operation property
webServiceAdapter.Operation = tempDom.xml;

// Run a query with the changed serviceUrl
webServiceAdapter.Query();

See also

Reference

WebServiceAdapter2 interface

WebServiceAdapter2 members

Operation overload

Microsoft.Office.Interop.InfoPath namespace