zoukankan      html  css  js  c++  java
  • WSSF的改造,让它更适合项目开发.

    WSSF 是 MS 实践与模式小组开发的一套分布式架构.相关内容见:http://www.cnblogs.com/LiYunQi/archive/2009/02/06/1385618.html

    我想在项目中应用它,所以先实践一下.

     如果用WSSF 。则要用以下调用:

    1.客户端调用:public string Hello(string Msg);

    2.代理类方法:public ResponseMessage Hello(RequestMessage Request);

    3.服务实现:

    protected MyService.BusinessLogic.MyServiceBusinessLogic busLogic = new BusinessLogic.MyServiceBusinessLogic();

    publicoverride MessageContracts.Response GetList(MessageContracts.Request request)
    {
    Responseres
    = new Response();
    res.ProductList
    = new DataContracts.ProductInfoList();
    //拆包,转换.
    res.ProductList.AddRange(busLogic.GetList(request.Msg).ConvertAll(TranslateBetweenProductInfoItemAndProductInfoItem.TranslateProductInfoItemToProductInfoItem));
    //包装返回 
    return res;
    }

    4.业务逻辑:

    public string GetList(stringrequest)

    {

      return "hello"+ request + "!";

    }

     

    1.去除MessageContract

     直接用实体替代。对于简单类型:stringInt。 直接调用更好。如下:

    1.客户端调用:public string Hello(string Msg);

    2.代理类方法:public string Hello(string Request);

    3.服务实现:

    protected MyService.BusinessLogic.MyServiceBusinessLogicbusLogic = new BusinessLogic.MyServiceBusinessLogic();

    public override string GetList(stringrequest)

    {

      return busLogic.GetList(request); //去除拆包,转换,包装返回三个步骤.

    }

     

    4.业务逻辑:

    public string GetList(stringrequest)

    {

      return "hello"+ request + "!";

    }

     

    2.去除业务逻辑层,保留业务实体层.用于返回数据把其内容移到服务实现:

     即把第三步改为:

    public override string GetList(stringrequest)

    {

      return "hello:"+ request; // 不再调用业务逻辑层,直接返回。

    }

    3.如果有ORM实体层,也可把业务实体层去除(或把Entity 当做是DataContract , 如果Entity 不能当作DataContract ,那么再自定义自己的DataContract). 但是系统编译会报警告:返回类型不符合CLS

     第三步即为:

    public partial  class ProductService: ProductServiceBase

    {

      public override MyOql.DictRule.EntityGetList(MyOql.DictRule.Entityrequest)

      {

        request.Value= "hello"+ request.Key;

        returnrequest;

      }

    }

     

    总结一下: WSSF 应该去除的项目有:

    MessageContract , BusinessEntities , DataAccess(用 ORM 替代.)

    应该改造的有:

    DataContract: 如果传输实体,那么直接用 Entity . 否则,自定义DataContract

    ServiceImplementation: 直接实现代码. 避免拆包,转换,包装.

     

    初学,欢迎拍砖!

    Demo 下载:https://files.cnblogs.com/newsea/MyService.rar

    alarm   作者:NewSea     出处:http://newsea.cnblogs.com/    QQ,MSN:iamnewsea@hotmail.com

      如无特别标记说明,均为NewSea原创,版权私有,翻载必纠。欢迎交流,转载,但要在页面明显位置给出原文连接。谢谢。
  • 相关阅读:
    SQL GUID和自增列做主键的优缺点
    python __future__ 的几种特性
    数据库中文乱码处理
    Android_Intent意图详解
    Windows Server 2012 R2超级虚拟化之六 Hyper-v Replica 2.0和Live migrations
    如今网站定位,需立足于用户
    Hibernate 数据的批量插入、更新和删除
    paip.提升用户体验---论文本编辑器的色彩方案
    时间管理方法学习
    网站优化:从搜索引擎到社交网络的艰难转变
  • 原文地址:https://www.cnblogs.com/newsea/p/1756900.html
Copyright © 2011-2022 走看看