您的位置:首页 > 其它

使用Fiddler解析WCF RIA Service传输的数据

2011-01-05 15:18 567 查看
使用Fiddler 2 解析WCF RIA Service传输的数据,您需要安装一个PlugIn。下载解压后,放在Inspectors文件中。重新启动Fiddler,你就会看到WCF Binary的选项。

下面的场景是,点一个Button根据ID查询数据,UI如下图:





Server端Code,ItemContext是DomainContext基类

var tt = new ItemContext();
tblItemDataGrid.ItemsSource = tt.tblItems;
EntityQuery<tblItem> s = tt.GetTblItemsByItemNumberQuery(txtItemNumber.Text == "" ? 0 : Convert.ToInt32(txtItemNumber.Text));
LoadOperation<tblItem> op = tt.Load(s);

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

此时我们通过Monitor可以看到类似下面文本:

@GetTblItemsByItemNumberResponsehttp://tempuri.org/@GetTblItemsByItemNumberResult    aDomainServices    i)http://www.w3.org/2001/XMLSchema-instance^
TotalCount�^
RootResults    b7http://schemas.datacontract.org/2004/07/RIAServices.Web_tblItem_ItemDescription�
Item Name1_
ItemNumber�_Quantity�


.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
就会被还原到这样的明文:

<GetTblItemsByItemNumberResponse xmlns="http://tempuri.org/">
<GetTblItemsByItemNumberResult xmlns:a="DomainServices" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:TotalCount>1</a:TotalCount>
<a:RootResults xmlns:b="http://schemas.datacontract.org/2004/07/RIAServices.Web">
<b:tblItem>
<b:ItemDescription>Item Name1</b:ItemDescription>
<b:ItemNumber>1</b:ItemNumber>
<b:Quantity>1</b:Quantity>
</b:tblItem>
</a:RootResults>
</GetTblItemsByItemNumberResult>
</GetTblItemsByItemNumberResponse>

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

是不是很实用,如果您是Debug本地的localhost的站点,可能需要修改hosts文件,或修改它的js配置。可以参考官方网站

本文所使用例子是 可参考 WCF RIA Services 快速上手

希望对您开发有帮助。

作者:Petter Liu
出处:http://www.cnblogs.com/wintersun/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
该文章也同时发布在我的独立博客中-Petter Liu Blog
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐