SOADEMO系统
从OTN可以下载到一个soademo_101310_preview.zip,这是SOADEMO的源码包,可以在JDeveloper中打开。
注意,这个包可能有点问题:如果这个包的根目录下有一个叫decisionservices的文件夹,请把它删除掉,因为它可能会造成编译无法通过,错误原因是duplicate class。
简介
这里我们虚构了一个叫做Global Company的公司,它的主要业务就是在网上卖电子产品,比如MP3等。从功能的角度来说,SOA Order Booking系统实现了“从客户登陆web client端填写订单,到后面的可能的人工批示,再到选择supplier(供货商),最后到选择自动选择发货方式和通知客户”。从技术的角度来说,它充分的展示了如何将现有的企业内部应用程序和企业外部应用程序组装在一起构成一整套流程。
下面这副图就是SOA Order Booking系统的一个overview,从中你可以看出它的大致流程。请注意,很多应用程序都“松耦合”的参与其中,它们不只是可以在SOA Order Booking系统中使用,也可以被别的系统使用。

流程详解
1、 客户使用SOADEMO-CLIENT浏览货物并填写订单(order),订单发出后会自动调用OrderBookingESB服务
2、 OrderBookingESB服务接到请求后调用SOAOrderBooking BPEL应用,该应用定义了SOA Order Booking系统的主要流程。
3、 SOAOrderBooking把订单插入到数据库中
4、 SOAOrderBooking调用CustomerService服务从数据库中提取客户信息
5、 SOAOrderBooking调用CreditService服务来检查客户的信用卡(credit card)是否合法。如果不合法,自动取消这个订单;否则,将订单和客户的具体情况一起发给RULES引擎(决策服务)
6、 SOAOrderBooking通过RULES引擎(决策服务)定义的规则来决定是否需要人工审批:
a) 如果用户的status是白金(platinum),无需人工审批
b) 如果用户的staus是金(gold),当订单的总额超过1000美元时需要人工审批
c) 如果用户的status是银(silver),不管订单大小都需要人工审批
7、 如果订单需要人工审批,SOAOrderBooking调用人工流程(human workflow),并给有关人员发送消息。
8、 如果订单需要人工审批,有关人员登陆到worklist应用程序,批准或拒绝。SOAOrderBooking收到拒绝回复时,取消该订单,否则进行下一步。
9、 SOAOrderBooking同时向SelectManufacturer服务和RapidService服务请求报价,这里:
a) SelectManufacturer是一级代理商,所以报价比较低,但是它响应不是非常及时,即它是异步返回报价
b) RapidService不是一级代理商,所以报价比较高,但是它以快取胜,会同步返回报价
10、 SOAOrderBooking收集两个供应商返回的报价,选择给出低报价的那个供应商。
11、 SOAOrderBooking调用ESB服务FulfillmentESB来决定发货(ship)的方式
12、 FulfillmentESB检查订单的大小
a) 如果订单小于500美元,选择USPS,这个系统是从一个目录下取订单的,所以要用File adapter(文件适配器)把订单写到指定的目录下。
b) 如果订单大于等于500美元,选择 Fedex,这个系统等待订单出现在一个指定的数据库表中,所以要使用Db adapter(数据库适配器)把订单写到此表中
c) 所有订单,不论发货商是谁(USPS或Fedex),都保存在一个临时的JIMS queue中(写入过程由JMS adapter实现),并在前一天晚上以批处理的方式upload。
13、 SOAOrderBooking保存订单的状态在数据库
14、 SOAOrderBooking通过BPEL提供的邮件(email)功能发邮件给客户。
每个服务用到的技术
上面已经说过
SOADEMO
中有近
10
个
project
,下面给出每个
project
使用到的技术。我们在这篇文章中不会谈太多的技术实现细节,而是
focus
在演示上。
Project
|
Technology and Techniques Used
|
CustomerService
|
■
Uses EJB 3.0 entity objects that are generated from database tables. JDeveloper is used to generate the entity objects.
■
Uses JSR-181 Web Services Metadata annotations.
■
Uses a stateless session bean as the session facade. The session bean is generated by JDeveloper.
|
CreditService
|
Shows "top-down" implementation of web services: starting with a WSDL file, you use JDeveloper to generate Java classes from the WSDL file.
|
RapidService
|
■
Shows "bottom-up" implementation of web services: starting with Java classes, you use JDeveloper to generate a WSDL file.
■
Uses JSR-181 Web Services Metadata annotations in the Java files
|
SelectManufacturer
|
Shows a simple asynchronous BPEL process with Receive
and Invoke activities.
|
FulfillmentESB
|
■
Shows routing services that use filters to check input data. The filters then direct the requests to the appropriate targets.
■
Uses transformation rules to transform data appropriately for writing to databases and files. Database adapters and file adapters perform the writes.
■
Shows a routing service that routes to a JMS adapter.
|
SOAOrderBooking
|
■
Shows how to use BPEL to orchestrate a flow sequence.
■
Invokes the services provided by all the projects (except for OrderBookingESB).
■
Invokes other BPEL flows (the SelectManufacturer BPEL project).
■
Invokes ESB project (the FulfillmentESB project).
■
Shows how to integrate Oracle Business Rules with BPEL.
■
Shows Decision Service.
■
Sends email through the Email service.
■
Uses the flow activity to send requests to RapidService and SelectManufacturer.
■
Uses the human task to set up a step that requires manual approval
|
OrderBookingESB
|
Invokes a BPEL project (the SOAOrderBooking project) by
using a SOAP service
|
SOADemo-Client
|
■
Shows how to invoke an ESB project from an ADF application (the "place order" button invokes the OrderBookingESB project).
■
Shows how to call the CustomerService project from the "login" button.
|