InfoPath的常见处理办法

1.动态调用WebUrl

  设置一个字段UrlField,用于存放Url

  public void OnLoad(DocReturnEvent e)

        {

            // Write your code here.

            IXMLDOMNode node = e.XDocument.DOM.documentElement.selectSingleNode("my:UrlField");

            this.WebSiteURL = node.text;

        }



        private void ApplyWebServiceURL(DataObject dataObj)

        {

            WebServiceAdapter adp = dataObj.QueryAdapter as WebServiceAdapter;

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(adp.Operation);

            XmlNode node = doc.SelectSingleNode("//@serviceUrl");

            node.Value = this.WebSiteURL;

            adp.Operation = doc.OuterXml;

        }

  

2.代码调用WebService

           //找到要调用的dataconnect

            DataObject dataObj = (DataObject)thisXDocument.DataObjects["SaveEvent"];

            if (dataObj == null)

            {

                thisXDocument.UI.Alert("The data connect SaveEvent does not exist.");

                return null;

            }

            //设置Web service的输入参数

            IXMLDOMNode nodeEntry;

            try

            {

                nodeEntry = dataObj.DOM.selectSingleNode("/dfs:myFields/dfs:queryFields/tns:SaveEvent");

                nodeEntry.selectSingleNode("tns:input").text = dataObj.DOM.xml;

            }

            catch (Exception ex)

            {

                string err = ex.Message;

            }

            //调用Web service

            this.ApplyWebServiceURL(dataObj);

            dataObj.Query();

            //得到Web service的返回值,是一个xmldocument,包括projectID,eventID两个值

            IXMLDOMNode nodeResult = dataObj.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/tns:SaveEventResponse/tns:SaveEventResult");

            string projectID,eventID;

            projectID = nodeResult.selectSingleNode("//ProjectID").text;

            eventID = nodeResult.selectSingleNode("//EventID").text;

  http://blog.csdn.net/yanwei100/article/details/740766

 

你可能感兴趣的:(Path)