您的位置:首页 > 其它

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

2013-10-13 23:29 471 查看
原文 /article/4752406.html

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

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





Server端Code,ItemContext是DomainContext基类

            var tt = new ItemContext();

[code] tblItemDataGrid.ItemsSource = tt.tblItems;

EntityQuery<tblItem> s = tt.GetTblItemsByItemNumberQuery(txtItemNumber.Text == "" ? 0 : Convert.ToInt32(txtItemNumber.Text));

LoadOperation<tblItem> op = tt.Load(s);

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

@GetTblItemsByItemNumberResponsehttp://tempuri.org/@GetTblItemsByItemNumberResult    aDomainServices    i)http://www.w3.org/2001/XMLSchema-instance^

[code]TotalCount�^

RootResults    b7http://schemas.datacontract.org/2004/07/RIAServices.Web_tblItem_ItemDescription�

Item Name1_

ItemNumber�_Quantity�

[/code]
就会被还原到这样的明文:

<GetTblItemsByItemNumberResponse xmlns="http://tempuri.org/">

[code] <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>

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

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

希望对您开发有帮助。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐