biztalk,BizTalk Server + SQL Server - 通过集成创造业务价值 [ 上篇 ]

概述
对于IT信息技术来说,应用程序和数据就好像太极的阴阳两极,通过对这两者进行组合,即可获得 IT的业务价值。虽然公司、ZF机关需要使用大量不同应用程序,并用不同格式存储数据,但为了从这种多样化中充分获益,往往需要用智能的方式将所有内容进行连接。换句话说,也就是需要集成!
在集成的过程中可能会产生很多非常麻烦的问题,通常存在于公司、ZF机关中的都是大量的异构系统、异构数据。每种应用程序拥有自己的立场和特有的表现形式,并且随着时间的流逝,IT环境慢慢变得更加复杂。根据不同业务的需求,会由不同部门在不同地点部署不同的应用程序和数据库。这些因素使得集成工作面临重大挑战,这种挑战有可能出自于技术上的,也有可能出自于业务上的。
为了面对这一挑战,我们通过BizTalk与SQL Server的结合,为业务创造出更大的价值。
  • BizTalk Server:其重点在于连接不同的应用系统,并基于SOA的架构对来自异构系统的服务进行流程编排和重组,从而对多个业务流程实现自动化;同时,也可以使用它进行某些类型的数据集成,并对数据进行权威清晰、过滤、比对等操作。
  • SQL Server:目标是使用更智能的方式来操作数据,这也就意味着需要在不同的应用系统间保持数据同步,或创建数据仓库等等。
在这篇文章中将介绍如何通过BizTalk将来自于各个异构应用系统的数据,传送到SQL Server数据库当中,并介绍如何使用BizTalk与数据库进行通信,如调用存储过程等等。

演示
场景介绍
在这里我们有一个SQL的存储过程,用来更新仓库库存量,现在我们要做一个BizTalk的POC(概念验证),当接收到仓库补充货源消息的时候,使用BizTalk去调用SQL Server中的存储过程,来更新仓库的库存量。在演示过程中,我们会用到WCF-SQL适配器去调用SQL存储过程,并且设计一个测试流程来转换补充货源的消息,并将其作为参数传送到存储过程中进行更新,最后将更新的结果通过WCF-SQL适配器插入到数据表当中。
1. InventoryUpdate解决方案:在这个解决方案中有2个工程文件,分别为InventoryUpdate.OrchestrationInventoryUpdate.Schema。Schema工程文件中包含一个名为StoreInventoryUpdate的架构文件,它用来表示一个来自于POS系统发送过来的更新玩具商店库存的消息。Orchestration工程文件目前没有内容,我们会在后面完善它。
1biztalk,BizTalk Server + SQL Server - 通过集成创造业务价值 [ 上篇 ]
2. 玩具店SQL Server存储过程:该存储过程用来更新玩具商店的库存表,该存储过程需要4个参数,分别为productID、qty、storeNumberChangeType。通过ChangeType来判断是增加还是减小库存量。一个非常简单的存储过程,其T-SQL代码如下所示
1: USE [TailspinToys]
2: GO
3: /****** Object: StoredProcedure [dbo].[sp_UpdateInventory] Script Date: 04/19/2011 15:26:17 ******/
4: SET ANSI_NULLS ON
5: GO
6: SET QUOTED_IDENTIFIER ON
7: GO
8: ALTER PROCEDURE [dbo].[sp_UpdateInventory]
9:
10: (
11: @productID int =0,
12: @qty int = 0,
13: @storeNumber int = 0,
14: @bChangeType int = 1
15: )
16:
17: /*
18: bChangeType : 0 = decrease
19: 1 = increase
20: */
21: AS
22:
23: Declare @newQty int;
24: Declare @table varchar(50);
25:
26: set @table = (SELECT TOP(1)
27: [dbo].[Stores].[InventoryTableName]
28: FROM [dbo].[Stores]
29: WHERE [dbo].[Stores].[StoreNumber] = @storeNumber);
30:
31: set @table = lower(@table);
32:
33: if @table = 'storeinventory_01'
34: Begin
35: if (@bChangeType = 1)
36: begin
37: --increase the qty
38: set @newQty = (Select qty from dbo.StoreInventory_01 where ProductID = @ProductID)+ @qty
39: end
40: else
41: begin
42: --decrease the qty
43: set @newQty = (Select qty from dbo.StoreInventory_01 where ProductID = @ProductID)- @qty
44:
45: end
46:
47: Update dbo.StoreInventory_01
48: Set Qty=@newQty
49: Where (ProductID = @productID)
50: End
51: Else if @table = 'storeinventory_02'
52: Begin
53: if (@bChangeType = 1)
54: begin
55: --increase the qty
56: set @newQty = (Select qty from dbo.StoreInventory_02 where ProductID = @ProductID)+ @qty
57: end
58: else
59: begin
60: --decrease the qty
61: set @newQty = (Select qty from dbo.StoreInventory_02 where ProductID = @ProductID)- @qty
62:
63: end
64:
65: Update dbo.StoreInventory_02
66: Set Qty = @newQty
67: Where (ProductID = @productID)
68: End
69:
70: Else if @table = 'storeinventory_03'
71: Begin
72:
73: if (@bChangeType = 1)
74: begin
75: --increase the qty
76: set @newQty = (Select qty from dbo.StoreInventory_03 where ProductID = @ProductID)+ @qty
77: end
78: else
79: begin
80: --decrease the qty
81: set @newQty = (Select qty from dbo.StoreInventory_03 where ProductID = @ProductID)- @qty
82:
83: end
84:
85: Update dbo.StoreInventory_03
86: Set Qty = @newQty
87: Where (ProductID = @productID)
88: End
89:
90: Else if @table = 'warehouse_inventory'
91: Begin
92:
93: if (@bChangeType = 1)
94: begin
95: --increase the qty
96: set @newQty = (Select qty from dbo.Warehouse_Inventory where ProductID = @ProductID)+ @qty
97: end
98: else
99: begin
100: --decrease the qty
101: set @newQty = (Select qty from dbo.Warehouse_Inventory where ProductID = @ProductID)- @qty
102:
103: end
104:
105: Update dbo.Warehouse_Inventory
106: Set Qty = @newQty
107: Where (ProductID = @productID)
108: End
109:
110: RETURN
Tags:  biztalk

延伸阅读

最新评论

发表评论