介绍
Silverlight 2.0 调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
    通过 System.Net.WebClient 类调用 REST 服务
    通过 System.Json 命名控件下的类处理 JSON 数据
    通过 System.Xml.Linq 命名空间下的类(LINQ to XML)处理 XML 数据
    通过 System.ServiceModel.Syndication 命名空间下的类处理 RSS/ATOM 数据


在线DEMO
http://www.cnblogs.com/webabcd/archive/2008/10/09/1307486.html


示例
1、调用 REST 服务,返回 JSON 数据
REST.cs(WCF创建的REST服务)
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据using System;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Linq;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Runtime.Serialization;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.ServiceModel;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.ServiceModel.Activation;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.ServiceModel.Web;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Collections.Generic;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Text;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.IO;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据

Json.xaml
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据<UserControl x:Class="Silverlight20.Communication.Json"
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据    xmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据    xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml">
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据    
<StackPanel HorizontalAlignment="Left" Width="600">
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据    
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据        
<TextBox x:Name="txtMsgJson" Margin="5" />
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据        
<TextBox x:Name="txtMsgJson2" Margin="5" /> 
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据        
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据    
</StackPanel>
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
</UserControl>
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据

Json.xaml.cs
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据using System;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Collections.Generic;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Linq;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Net;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Windows;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Windows.Controls;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Windows.Documents;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Windows.Input;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Windows.Media;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Windows.Media.Animation;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Windows.Shapes;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.IO;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
namespace Silverlight20.Communication


2、调用 REST 服务,返回 XML 数据
REST.cs(WCF创建的REST服务)
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据using System;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Linq;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Runtime.Serialization;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.ServiceModel;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.ServiceModel.Activation;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.ServiceModel.Web;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Collections.Generic;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Text;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.IO;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据

Xml.xaml
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据<UserControl x:Class="Silverlight20.Communication.Xml"
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据    xmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据    xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml">
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据    
<StackPanel HorizontalAlignment="Left" Width="600">
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据        
<TextBox x:Name="txtMsgXml" Margin="5" />
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据        
<TextBox x:Name="txtMsgXml2" Margin="5" />
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据    
</StackPanel>
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
</UserControl>
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据

Xml.xaml.cs
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据using System;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Collections.Generic;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Linq;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Net;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Windows;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Windows.Controls;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Windows.Documents;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Windows.Input;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Windows.Media;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Windows.Media.Animation;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Windows.Shapes;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Xml.Linq;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.IO;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
namespace Silverlight20.Communication


3、调用 REST 服务,返回 Rss/Atom 数据
Proxy.aspx.cs(返回指定的url地址的内容的服务)
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据using System;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Collections.Generic;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Linq;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Web;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Web.UI;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Web.UI.WebControls;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
public partial class Proxy : System.Web.UI.Page

RssAtom.xaml
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据<UserControl x:Class="Silverlight20.Communication.RssAtom"
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据    xmlns
="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据    xmlns:x
="http://schemas.microsoft.com/winfx/2006/xaml">
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据    
<StackPanel HorizontalAlignment="Left" >
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据        
<TextBox x:Name="txtMsgRss" Width="600" Margin="5" />
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据        
<StackPanel Orientation="Horizontal">
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据        
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据            
<ListBox x:Name="list" Width="300" Margin="5" SelectionChanged="list_SelectionChanged">
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据                
<ListBox.ItemTemplate>
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据                    
<DataTemplate>
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据                        
<TextBlock Text="{Binding Title.Text}"></TextBlock>
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据                    
</DataTemplate>
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据                
</ListBox.ItemTemplate>
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据            
</ListBox>
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据            
<TextBlock x:Name="detail" Width="300" Margin="5" Text="{Binding Summary.Text}" TextWrapping="Wrap" />
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据            
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据        
</StackPanel>
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据        
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据    
</StackPanel>
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
</UserControl>
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据

RssAtom.xaml.cs
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据using System;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Collections.Generic;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Linq;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Net;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Windows;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Windows.Controls;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Windows.Documents;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Windows.Input;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Windows.Media;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Windows.Media.Animation;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Windows.Shapes;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.Xml;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.IO;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
using System.ServiceModel.Syndication;
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
2.0通信之调用REST服务,处理JSON格式, XML格式, RSS/ATOM格式的数据
namespace Silverlight20.Communication


相关文章: