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


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

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

          RIAdemo_snap

         Server端Code,ItemContext是DomainContext基类

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

           此时我们通过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�

             就会被还原到这样的明文:

    <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>

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

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

      希望对您开发有帮助。


    作者:Petter Liu
    出处:http://www.cnblogs.com/wintersun/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
    该文章也同时发布在我的独立博客中-Petter Liu Blog

  • 相关阅读:
    eclipse报错 : One or more constraints have not been satisfied.
    关于一个计算机同时装两个jdk对应两个eclipse
    开发测试类2
    工作中测试类1
    Spring 读取classpath下的文件存到map里面
    CentOS6下安装JDK并且部署tomcat容器
    ConOS安装mysql5.7 及简单配置
    用sqlyog迁移mysql数据库
    FindBugs缺陷库
    使用NumberPicker定制自己喜欢的Date&TimePicker
  • 原文地址:https://www.cnblogs.com/wintersun/p/1926386.html
Copyright © 2020-2023  润新知