会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
人生就是一场圣战-GODWAR
最大的敌人就是自己 No incapable except unthinkable. God helps those who help themselves
博客园
首页
新随笔
联系
订阅
管理
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; }
}
}
}
posted on
2008-03-28 19:36
巍巍边疆
阅读(
981
) 评论(
0
)
收藏
举报
刷新页面
返回顶部