WebService传XML 简单实例传送 [WebMethod] public XmlDataDocument GetSiteAData(string AssignName) { XmlDataDocument xd = n...
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 简单实例
基础教程推荐
猜你喜欢
- springboot自定义starter方法及注解实例 2023-03-31
- java实现多人聊天系统 2023-05-19
- java基础知识之FileInputStream流的使用 2023-08-11
- ConditionalOnProperty配置swagger不生效问题及解决 2023-01-02
- Java实现查找文件和替换文件内容 2023-04-06
- Java数据结构之对象比较详解 2023-03-07
- Java并发编程进阶之线程控制篇 2023-03-07
- JDK数组阻塞队列源码深入分析总结 2023-04-18
- Java文件管理操作的知识点整理 2023-05-19
- Java实现线程插队的示例代码 2022-09-03