SOA Suite 11g 开发指南之十三:使用SDO 访问与操作数据

声明:该博文来自热爱JAVA,热爱生活。原文地址http://maping930883.blogspot.com/

本实验的内容如下:
(1)在SOA中使用SDO(Service Data Object)访问与操作数据库中的数据。
(2)使用ADF BC创建符合SDO标准的服务:访问数据与更新数据。

重要步骤说明:

1. 创建Customers表
sqlplus soademo/soademo @create_customers_table.sql

CREATE TABLE CUSTOMERS
(
CUSTOMER_ID VARCHAR2(10) NOT NULL PRIMARY KEY,
CUSTOMER_NAME VARCHAR2(255) NOT NULL,
LAST_ORDER_NUMBER VARCHAR2(4000),
LAST_ORDER_AMOUNT NUMBER(10,2)
);

INSERT INTO CUSTOMERS VALUES ('1111', 'Test Customer', NULL, NULL);

COMMIT;

[b]2. 创建CustomerSDO Project 时,选择ADF Business Components。[/b]

[img]http://dl.iteye.com/upload/attachment/0071/8811/35aff764-2988-305c-9e10-95e44bd6c9d8.png[/img]

[b]3. 在AM中创建Service Interface时,选择所有Basic Operations。[/b]

[img]http://dl.iteye.com/upload/attachment/0071/8813/faa38f6a-49e8-348f-b5ec-ac7e9bbfb41d.png[/img]

4. 修改CustomerSDOService Configuration的Datasource为jdbc/soademoDatabase。

[img]http://dl.iteye.com/upload/attachment/0071/8815/8c7b138b-d946-34ab-8ec1-9c6580b9bc59.png[/img]

5. 设置应用默认的Configuration为CustomerSDOService。

[img]http://dl.iteye.com/upload/attachment/0071/8817/888b64f1-0df7-3dbc-9e36-50d95491849a.png[/img]

6. 修改Java EE Application名称。

[img]http://dl.iteye.com/upload/attachment/0071/8819/b2b55d86-6603-310a-8ff5-0f4a46d115d9.png[/img]

7. 创建Deployment Profile,选择类型:Business Components Service Interface。

[img]http://dl.iteye.com/upload/attachment/0071/8821/df20b4bc-9e9b-3c2f-abbe-b96d92168264.png[/img]

8. 修改EAR 名称,Enterprise Application Name。

[img]http://dl.iteye.com/upload/attachment/0071/8823/287f8911-c752-3ce0-92e5-78769bba4720.png[/img]

9. 创建WebService Reference,WSDL地址来自于刚刚发布的CustomerSDOService。

[img]http://dl.iteye.com/upload/attachment/0071/8825/e28c0a9b-e380-3267-a934-5c3bf85051c8.png[/img]

10. customer-app应用的访问URL:http://localhost:7001/customer-app/CustomerSDOService。
在这里可以测试,也可以找到WSDL地址。

[img]http://dl.iteye.com/upload/attachment/0071/8827/9b71c831-e7ed-3cca-a2ca-8dff6449b7e6.png[/img]

11. 创建Entity Variable,其类型为customersViewSDO。

[img]http://dl.iteye.com/upload/attachment/0071/8829/41e87cd5-b682-3928-91b3-469121a9d501.png[/img]

12. 设置partner link 为CustomerSDOService。

[img]http://dl.iteye.com/upload/attachment/0071/8831/7dee9678-dbe7-3b7e-b76d-28612ae25eac.png[/img]

13. 将刚创建的Entity Variable中的CustomerId与Input变量中CustomerId做关联绑定。
绑定后,当进入ApproveLargeOrder后,自动会根据传入的CustomerId,CustomerInfoEV自动获取Customer信息。
并且,该记录就成为当前记录。任何对该Entity Variable的改动,都将反映到数据库表中,因为Entity Variable与CustomerSDOService已经绑定了。

[img]http://dl.iteye.com/upload/attachment/0071/8833/87bd0500-d3c1-37fe-9764-a1973aaf3060.png[/img]

14. 把Entity Variable变量中的Customer Name 赋值给Input变量中的Customer Id。

[img]http://dl.iteye.com/upload/attachment/0071/8835/868b6d18-e6dd-321f-99e3-eb2be610d6c1.png[/img]

15. 把Output变量中的一些值赋值给Entity Variable变量中的对应值。
修改后的值,将会修改数据库,因为Entity Variable与CustomerSDOService已经绑定了。

[img]http://dl.iteye.com/upload/attachment/0071/8837/75f3eef4-1357-3b8c-9943-92448a3e49c8.png[/img]

16. 测试。
如果顺利的话,应该能看到传入的消息中,Customer Id的值是Customer Name的值。
并且,查看数据库,会发现数据已经被更改了。
测试数据如下:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body xmlns:ns1="http://xmlns.oracle.com/ns/order">
<ns1:PurchaseOrder>
<ns1:CustID>1111</ns1:CustID>
<ns1:ID>2222</ns1:ID>
<ns1:productName>iPod shuffle</ns1:productName>
<ns1:itemType>Electronics</ns1:itemType>
<ns1:price>145</ns1:price>
<ns1:quantity>30</ns1:quantity>
<ns1:status>Initial</ns1:status>
<ns1:ccType>Mastercard</ns1:ccType>
<ns1:ccNumber>1234-1234-1234-1234</ns1:ccNumber>
</ns1:PurchaseOrder>
</soap:Body>
</soap:Envelope>

[img]http://dl.iteye.com/upload/attachment/0071/8839/564f1e68-6fd7-37d9-b906-e1450a07e6bf.png[/img]


[img]http://dl.iteye.com/upload/attachment/0071/8841/fc76b2fa-1822-39e5-9fbc-8a5221e1c9c7.png[/img]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值