无为清净楼资源网 Design By www.qnjia.com

WebService传XML 简单实例

传送

    [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) //为所有元素加上站点名称标记
      {
        XmlElement Link = xd.CreateElement("SiteName");
        Link.InnerText = ConfigurationSettings.AppSettings["SiteName"].ToString();
        roota.AppendChild(Link);
      }
    return xd;
  }

异步调用

  IAsyncResult ar1;
    IAsyncResult ar2;

    localhost.WebService serviceA = new localhost.WebService();
    XmlNode xmlNode1;
    XmlNode xmlNode2;


    ////直接调用
    //xmlNode1 = serviceA.GetSiteAData("2");
    //异步调用
    ar1 = 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();

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

标签:
WebService传XML,WebService传XML,如何实现,WebService传XML,实例

无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com