WebServiceAdapter2.Operation 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置与对象的表单定义 (.xsf) 文件WebServiceAdapterObject中包含的操作元素对应的 XML 字符串 ('outer XML') 。
public:
property System::String ^ Operation { System::String ^ get(); void set(System::String ^ value); };
public string Operation { get; set; }
member this.Operation : string with get, set
Public Property Operation As String
属性值
实现
示例
在以下示例中,对象的 Operation 属性 WebServiceAdapterObject 用于检索 .xsf 文件中 操作 元素的属性。 更新 WebServiceAdapter 的 serviceUrl,然后Query()调用 WebServiceAdapter 的 方法:
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.<span class="label">Operation</span> = tempDom.xml;
// Run a query with the changed serviceUrl
webServiceAdapter.Query();
注解
.xsf 文件的 operation 元素包含有关 Web 服务的信息,包括 Web 方法的名称、用于检索和提交数据的方法以及它的统一资源定位器 (URL)。
重要提示:此成员只能由与当前打开的窗体在同一域中运行的表单访问,或者由已授予跨域权限的表单访问。