Simple XML transfer instance for WebService and webservicexml instance

Source: Internet
Author: User

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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.