您的位置:知识库 » .NET技术

一步一步学Silverlight :数据与通信之ASMX

作者: TerryLee  来源: 博客园  发布时间: 2008-10-09 11:47  阅读: 5344 次  推荐: 0   原文链接   [收藏]  

 

实现该服务,定义一个GetPosts方法:

public class BlogService : WebService
{
    [WebMethod]
    public Post[] GetPosts()
    {
        List<Post> posts = new List<Post>()
        {
            new Post{ Id=1, Title="一步一步学Silverlight 2系列(13):数据与通信之WebRequest", Author="TerryLee" },
            new Post{ Id=2, Title="一步一步学Silverlight 2系列(12):数据与通信之WebClient", Author="TerryLee" },
            new Post{ Id=3, Title="一步一步学Silverlight 2系列(11):数据绑定", Author="TerryLee" },
            new Post{ Id=4, Title="一步一步学Silverlight 2系列(10):使用用户控件", Author="TerryLee" },
            new Post{ Id=5, Title="一步一步学Silverlight 2系列(9):使用控件模板", Author="TerryLee" },
            new Post{ Id=6, Title="一步一步学Silverlight 2系列(8):使用样式封装控件观感", Author="TerryLee" }
        };

        return posts.ToArray();
    }
}

同样设置Web Development Server的端口号为一个固定值,这里设为8081,然后在浏览器中测试服务是否正确:

TerryLee_Silverlight2_0069

点击调用后测试服务正确

TerryLee_Silverlight2_0070

在Silverlight项目中,添加对服务引用,

TerryLee_Silverlight2_0071

使用对象浏览器查看一下生成客户端代理类中的对象:

TerryLee_Silverlight2_0072

 

0
0

.NET技术热门文章

    .NET技术最新文章

      最新新闻

        热门新闻