zoukankan      html  css  js  c++  java
  • 清风乱谈 之 基于WCF的电子商务解决方案(一)

    首先,先用这个图片来说明我上次提到的多个组件服务器与WEB服务器之间的关系

     

    这么做至少有3个明显的好处:

    1.         将站点的压力平均化,提高网站的浏览速度,降低服务器压力。

    2.         保证各个应用组件之间逻辑的绝对分离,实现了我们说的低耦合。

    3.         应用服务器的接口可以多次复用,企业可以通过重新组合应用服务器接口建立统一的电子商务体系。

     

     

    该程序在VS2008下的结构如下:

     

    其中Orders对应着 订单管理组件服务系统”,Products对应着“产品目录管理组件服务系统”,Marketing对应着“市场营销及促销组件服务系统”,多个组件可以以IIS为宿主分别架设在多台服务器上。

     

     

    这里是IIS宿主站点的配置:

     

     

    以下为WEB服务器对组件服务器接口的调用方法:

    public void UpdateQuantity(Guid productID, int quantity)

            {

                //此处为对产品目录管理组件服务系统中提供的Product GetProductByID(Guid productID);接口的调用

                Product product = ServiceLoader.LoadService<IProduct>().GetProduct(productID);

                if (product.Inventory < quantity)

                {

                    throw new BusinessException("Lack of inventory.");

                }

                OrderDetail detail = this.Order.Details.Where(item => item.ProductID == productID).ToArray<OrderDetail>()[0];

                detail.Quantity = quantity;

                this.View.BindingOrderInfo(this.Order);

            }

     

     

     

    这段为接口调用在WEB.CONFIG文件里面的相关配置代码

    <client>

                  <endpoint address="http://localhost/PetShop/Products/productservice.svc" behaviorConfiguration="petShopBehavior"binding="ws2007HttpBinding"  contract="Artech.PetShop.Products.Service.Interface.IProductService" name="productservice"/>

                  <endpoint address="http://localhost/PetShop/Infrastructures/MembershipService.svc" behaviorConfiguration="petShopBehavior"binding="ws2007HttpBinding"  contract="Artech.PetShop.Infrastructures.Service.Interface.IMembershipService" name="membershipservice"/>

                  <endpoint address="http://localhost/PetShop/Orders/OrderService.svc" behaviorConfiguration="petShopBehavior" binding="ws2007HttpBinding" contract="Artech.PetShop.Orders.Service.Interface.IOrderService" name="orderservice"/>

             </client>

     

  • 相关阅读:
    一行代码搞定Dubbo接口调用
    测试周期内测试进度报告规范
    jq 一个强悍的json格式化查看工具
    浅析Docker容器的应用场景
    HDU 4432 Sum of divisors (水题,进制转换)
    HDU 4431 Mahjong (DFS,暴力枚举,剪枝)
    CodeForces 589B Layer Cake (暴力)
    CodeForces 589J Cleaner Robot (DFS,或BFS)
    CodeForces 589I Lottery (暴力,水题)
    CodeForces 589D Boulevard (数学,相遇)
  • 原文地址:https://www.cnblogs.com/kelamayi/p/1731508.html
Copyright © 2011-2022 走看看