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>

     

  • 相关阅读:
    How does a single thread run on multiple cores?
    一篇所有研究生都该读的好文:阳光温热 科研静好
    Running Slic3r from git on GNU Linux
    3D打印的各种问题及解决方案
    新工科的新视角:面向可持续竞争力的敏捷教学体系
    What is Modularity
    3d打印模型为什么文件格式必须是stl和stp的?
    剑指offer 39.平衡二叉树
    剑指offer 38.二叉树的深度
    剑指offer 37.数字在排序数组中出现的次数
  • 原文地址:https://www.cnblogs.com/kelamayi/p/1731508.html
Copyright © 2011-2022 走看看