zoukankan      html  css  js  c++  java
  • IList Webservice 序列化

    using System;
    using System.Collections;
    using System.Web;
    using System.Web.Services;
    using System.Web.Services.Protocols;
    using System.Xml.Serialization;

    [WebService(Namespace 
    = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo 
    = WsiProfiles.BasicProfile1_1)]
    public class Service : System.Web.Services.WebService
    {
        
    public Service () {

            
    //Uncomment the following line if using designed components 
            
    //InitializeComponent(); 
        }


        [WebMethod]
        
    public string HelloWorld() {
            
    return "Hello World";
        }


        [WebMethod]
        [XmlInclude(
    typeof(Article))]  
        
    public IList GetArticleList()
        
    {
            IList result 
    = new ArrayList();
            
    for (int i = 0; i < 20; i++)
            
    {
                
    string title = string.Format("新闻标题-{0}", i);
                
    string content = string.Format("新闻内容-{0}", i);
                DateTime time 
    = DateTime.Now.AddDays(i);
                result.Add(
    new Article(title, content, time));
            }

            
    return result;
        }


       
        
    public  class Article
        
    {
            
    private string title;
            
    private string content;
            
    private DateTime time;

            
    public Article()
            
    {
            
            }


            
    public Article(string title,string content,DateTime time)
            
    {
                
    this.title = title;
                
    this.content = content;
                
    this.time = time;
            }


            
    public string Title
            
    {
                
    get return title; }
                
    set { title = value; }
            }


            
    public string Content
            
    {
                
    get return content; }
                
    set { content = value; }
            }


            
    public DateTime Time
            
    {
                
    get return time; }
                
    set { time = value; }
            }

        }

    }

     
  • 相关阅读:
    MySQL存储过程和函数
    MySQL数据类型
    MySQL—基础(SQL语句)
    如何将一串字符串按照某个特定的字符分割后倒叙输出,如:www.baidu.com输出为com.baidu.www
    JAVA WEB数据中文编码问题
    如何用一条SQL语句从登录日志表中查询统计出每个人登录的次数
    JAVA WEB tomcat启动关闭问题
    thinkphp知识点
    smarty模板内容
    smarty基础
  • 原文地址:https://www.cnblogs.com/godwar/p/1128126.html
Copyright © 2011-2022 走看看