各子系統關系
網上商城系統包含四個部分:Store, Inventory,Shipping 和process Management。這四部分的關系 如下圖所示:
系統關系圖
Store
普通用戶使用的系統。提供商品浏覽,訂購等功能。
Inventory
商品庫存管理系統。為商品管理人員使用。
Shipping
商品配送系統。商品配送人員使用。
Process Management
流程管理,用於協調和系統之間的功能。
上述系統之間可以發生很多業務流程,其中“用戶下訂單”為一個重要流程。下面將描述這個流程的 處理過程,以及對各個系統的要求。
本系統所有子系統均采用NetBeans IDE開發,其中Store, Inventory和Shipping為基於JavaEE5的應用 。Process Management為基於Open-ESB的Composite Application。
四個項目的如下圖所示:
其中Order_Process為訂單流程的BPEL項目,它被包含在Process_Management項目中,作為其中一個 JBI模塊。
訂單處理流程
訂單處理流程圖
訂單處理流程圖
訂單處理過程描述
下訂單
用戶通過網上商城下訂單,Store系統通過發送訂單信息到指定的JMS Message Destination,觸發訂 單流程啟動。
訂單信息
約定訂單信息為xml格式,訂單內容如下圖所示:
訂單內容
Schema文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://xml.netbeans.org/schema/orderSchema"
xmlns:tns="http://xml.netbeans.org/schema/orderSchema"
elementFormDefault="qualified">
<xsd:element name="order">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="orderid">
<xsd:simpleType>
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
</xsd:element>
<xsd:element name="userid">
<xsd:simpleType>
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
</xsd:element>
<xsd:element name="orderitem" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="goodsid">
<xsd:simpleType>
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
</xsd:element>
<xsd:element name="count" type="xsd:int"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema><?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://xml.netbeans.org/schema/orderSchema"
xmlns:tns="http://xml.netbeans.org/schema/orderSchema"
elementFormDefault="qualified">
<xsd:element name="order">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="orderid">
<xsd:simpleType>
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
</xsd:element>
<xsd:element name="userid">
<xsd:simpleType>
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
</xsd:element>
<xsd:element name="orderitem" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="goodsid">
<xsd:simpleType>
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
</xsd:element>
<xsd:element name="count" type="xsd:int"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="address">
<xsd:simpleType>
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
</xsd:element>
<xsd:element name="tel">
<xsd:simpleType>
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
庫存檢查
根據庫存情況和訂單信息檢查訂單是否為有效訂單。
此過程調用庫存系統的Inventory Web Service接口獲取該訂單是否有效。
Inventory Web Service接口的輸入信息為訂單信息,輸出信息為“true” 或者“false”。
如果為“true”表示訂單有效:
調用Shipping系統提供的Shipping Web Service增加配送信息;
設置整個流程的返回值為“false”,通知store訂單處理成功;
整個訂單處理流程結束。
如果為“false”表示訂單無效,
設置整個流程的返回值為“false”,通知store訂單處理不成功;
整個訂單處理流程結束。
說明:庫存系統在檢查訂單同時,如果訂單有效會更新庫存信息。
Inventory Web Service的WSDL如下:
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="Inventory" targetNamespace="http://j2ee.netbeans.org/wsdl/Inventory"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://j2ee.netbeans.org/wsdl/Inventory" xmlns:plnk="http://docs.oasis- open.org/wsbpel/2.0/plnktype" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns="http://xml.netbeans.org/schema/orderSchema" xmlns:ns0="http://xml.netbeans.org/schema/OrderResult">
<types>
<xsd:schema targetNamespace="http://j2ee.netbeans.org/wsdl/Inventory">
<xsd:import namespace="http://xml.netbeans.org/schema/orderSchema" schemaLocation="orderSchema.xsd"/>
<xsd:import namespace="http://xml.netbeans.org/schema/OrderResult" schemaLocation="OrderResult.xsd"/>
</xsd:schema>
</types>
<message name="getinventoryCountRequest">
<part name="part1" type="xsd:string"/>
</message>
<message name="getinventoryCountReply">
<part name="part1" type="xsd:int"/>
</message>
<message name="InventoryOperationRequest">
<part name="part1" element="ns:order"/>
</message>
<message name="InventoryOperationReply">
<part name="part1" element="ns0:result"/>
</message>
<portType name="inventoryPortType">
<operation name="checkOrderAvailable">
<input name="input2" message="tns:InventoryOperationRequest"/>
<output name="output2" message="tns:InventoryOperationReply"/>
</operation>
</portType>
<binding name="InventoryBinding" type="tns:inventoryPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="checkOrderAvailable">
<input name="input2">
<soap:body use="literal" namespace="http://j2ee.netbeans.org/wsdl/Inventory"/>
</input>
<output name="output2">
<soap:body use="literal" namespace="http://j2ee.netbeans.org/wsdl/Inventory"/>
</output>
</operation>
</binding>
<service name="InventoryService">
<port name="InventoryPort" binding="tns:InventoryBinding">
<soap:address location="http://localhost:8080/Inventory/InventoryService"/>
</port>
</service>
<plnk:partnerLinkType name="Inventory1">
<!-- A partner link type is automatically generated when a new port type is added. Partner link types are used by BPEL processes.
In a BPEL process, a partner link represents the interaction between the BPEL process and a partner service. Each partner link is associated with a partner link type.
A partner link type characterizes the conversational relationship between two services. The partner link type can have one or two roles.-->
<plnk:role name="inventoryPortTypeRole" portType="tns:inventoryPortType"/>
</plnk:partnerLinkType>
</definitions>
增加配送信息
在訂單有效的情況下,Process Management會調用Shipping系統提供的Shipping Web Service增加配 送信息。
Shipping Web Service的輸入信息為訂單信息,輸出信息為“True”或者“False”。
Shipping Web Service的WSDL信息如下:
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="Shipping" targetNamespace="http://j2ee.netbeans.org/wsdl/Shipping"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://j2ee.netbeans.org/wsdl/Shipping" xmlns:ns="http://xml.netbeans.org/schema/orderSchema" xmlns:ns0="http://xml.netbeans.org/schema/OrderResult" xmlns:plnk="http://docs.oasis- open.org/wsbpel/2.0/plnktype" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<types>
<xsd:schema targetNamespace="http://j2ee.netbeans.org/wsdl/Shipping">
<xsd:import namespace="http://xml.netbeans.org/schema/OrderResult" schemaLocation="OrderResult.xsd"/>
<xsd:import namespace="http://xml.netbeans.org/schema/orderSchema" schemaLocation="orderSchema.xsd"/>
</xsd:schema>
</types>
<message name="ShippingOperationRequest">
<part name="part1" element="ns:order"/>
</message>
<message name="ShippingOperationReply">
<part name="part1" element="ns0:result"/>
</message>
<portType name="ShippingPortType">
<operation name="ShippingOperation">
<input name="input1" message="tns:ShippingOperationRequest"/>
<output name="output1" message="tns:ShippingOperationReply"/>
</operation>
</portType>
<binding name="ShippingBinding" type="tns:ShippingPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="ShippingOperation">
<soap:operation/>
<input name="input1">
<soap:body use="literal"/>
</input>
<output name="output1">
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="ShippingService">
<port name="ShippingPort" binding="tns:ShippingBinding">
<soap:address location="http://localhost:8080/Shipping/ShippingService"/>
</port>
</service>
<plnk:partnerLinkType name="Shipping1">
<!-- A partner link type is automatically generated when a new port type is added. Partner link types are used by BPEL processes.
In a BPEL process, a partner link represents the interaction between the BPEL process and a partner service. Each partner link is associated with a partner link type.
A partner link type characterizes the conversational relationship between two services. The partner link type can have one or two roles.-->
<plnk:role name="ShippingPortTypeRole" portType="tns:ShippingPortType"/>
</plnk:partnerLinkType>
</definitions>
返回訂單確認
Process Management 系統把訂單結果信息發送到某個指定的JMS Message Destination。
Store系統通過監聽該Destination獲取訂單確認結果,更新本系統的訂單的狀態。
訂單確認結果的數據結果有下列的Schema定義:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://xml.netbeans.org/schema/OrderConfirmResult"
xmlns:tns="http://xml.netbeans.org/schema/OrderConfirmResult"
elementFormDefault="qualified">
<xsd:element name="orderresult">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="orderid" type="xsd:string"></xsd:element>
<xsd:element name="isSuccess" type="xsd:boolean"></xsd:element>
<xsd:element name="comments" type="xsd:string"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
下面是兩個訂單確認的結果,第一個為成功的訂單,第二個為不成功的訂單。
成功的訂單確認結果:
<orderresult xmlns="http://xml.netbeans.org/schema/OrderConfirmResult">
<ns1:orderid xmlns:ns1="http://xml.netbeans.org/schema/OrderConfirmResult" xmlns:ord="http://xml.netbeans.org/schema/orderSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">1</ns1:orderid>
<ns1:isSuccess xmlns:ns1="http://xml.netbeans.org/schema/OrderConfirmResult">true</ns1:isSuccess>< BR> <ns1:comments xmlns:ns1="http://xml.netbeans.org/schema/OrderConfirmResult">Thanks for order</ns1:comments>
</orderresult>
不成功的訂單確認結果:
<orderresult xmlns="http://xml.netbeans.org/schema/OrderConfirmResult">
<ns1:orderid xmlns:ns1="http://xml.netbeans.org/schema/OrderConfirmResult" xmlns:ord="http://xml.netbeans.org/schema/orderSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">2</ns1:orderid>
<ns1:isSuccess xmlns:ns1="http://xml.netbeans.org/schema/OrderConfirmResult">false</ns1:isSuccess>
<ns1:comments xmlns:ns1="http://xml.netbeans.org/schema/OrderConfirmResult">Sorry,we have no enough goods</ns1:comments>
</orderresult>