Simple XML transfer instance for WebService and webservicexml instance
Simple XML transfer instance for WebService
Transfer
[WebMethod]
Public XmlDataDocument GetSiteAData (string AssignName) {XmlDataDocument xd = new XmlDataDocument (); DataSet ds = BusinessWork. businessWorkDataSet ("TreeView1"); xd = new XmlDataDocument (ds); XmlNode root1 = xd. documentElement; XmlNodeList roots = root1.SelectNodes ("url"); foreach (XmlNode roota in roots) // mark all elements with the site name {XmlElement Link = xd. createElement ("SiteName"); Link. innerText = ConfigurationSettings. appSettings ["SiteName"]. toString (); roota. appendChild (Link);} return xd ;}
Asynchronous call
IAsyncResult ar1; IAsyncResult ar2; localhost. webService serviceA = new localhost. webService (); XmlNode xmlNode1; XmlNode xmlNode2; // directly call // xmlNode1 = serviceA. getSiteAData ("2"); // call ar1 asynchronously = serviceA. beginGetSiteAData ("3", null, null); ar2 = serviceA. beginGetSiteAData ("2", null, null); xmlNode1 = serviceA. endGetSiteAData (ar1); xmlNode2 = serviceA. endGetSiteAData (ar2); StringBuilder xmlString1; xmlString1 = new StringBuilder (xmlNode1.OuterXml); XmlDataDocument xd = new XmlDataDocument (); xd. loadXml (xmlString1.ToString (); DataSet ds = new DataSet (); ds. readXml (new XmlNodeReader (xd); GridView1.DataSource = ds. tables [0]; GridView1.DataBind ();
Thank you for reading this article. I hope it will help you. Thank you for your support for this site!