[转载]清风乱谈 之 基于WCF的电子商务解决方案(一)

[转载]清风乱谈 之 基于WCF的电子商务解决方案(一) – 清风的.net研究小院 – 博客园.

首先,先用这个图片来说明我上次提到的多个组件服务器与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>

本次文章重点在把我昨天提出的理论找出一些实际的例子进行演示说明,这个码字和说话毕竟是有点区别 的,希望大家可以理解~

赞(0) 打赏
分享到: 更多 (0)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏