加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

AM使用指南之四:把AM中的方法发布为WebService

发布时间:2020-12-16 23:24:37 所属栏目:安全 来源:网络整理
导读:开发环境:JDeveloper 11.1.2.1.0 + Oracle XE Database 10gR2。 实际应用中,我们经常需要在AM中添加自己的方法,这些方法可以以Data Control的方式暴露出来,供ADF Faces使用。 但那些使用了非ADF技术开发的应用如何使用AM中的方法呢? 这里介绍最简便的一
开发环境:JDeveloper 11.1.2.1.0 + Oracle XE Database 10gR2。

实际应用中,我们经常需要在AM中添加自己的方法,这些方法可以以Data Control的方式暴露出来,供ADF Faces使用。
但那些使用了非ADF技术开发的应用如何使用AM中的方法呢?
这里介绍最简便的一种方法:把AM中的方法暴露成WebService。
重要步骤说明:
1. 创建应用时选择General Application,为Project1增加ADF BC Components。


2. Create Entities from Table: 选择Employee表。
3. 生成 AM Impl类。


增加如下方法:
/* 更新员工的工资 */
public void updateSalary(Number employeeId,Number salary) {
Key key = new Key(new Object[] { employeeId });
Row row = this.getEmployeesView1().getRow(key);
row.setAttribute("Salary",salary);
try {
this.getDBTransaction().commit();
} catch (Exception ex) {
ex.printStackTrace();
}
/* 获取员工的工作的总时间(多少个月) */
public Number emplWorkLoad(Number employeeId) {
this.getJobHistoryView1().setNamedWhereClauseParam("bv_employeeId",employeeId);
this.getJobHistoryView1().executeQuery();
if (this.getJobHistoryView1().first() != null) {
return (Number)this.getJobHistoryView1().first().getAttribute("WorkLoad");
return null;
4. 手工创建JobHistory VO,选择Read-Only through SQL query。


别忘了在AM的Data Model中,手工加入JobHistoryView。
5. 修改AM的Java和Service Interface选项。
在Client Interface中加入updateSalary和emplWorkLoad方法,这两个方法将会在Data Control中显示出来。
在Service Interface中加入updateSalary和emplWorkLoad方法,这两个方法将会被发布为WebService。


6. 修改AM的Configuration选项。
因为要发布到独立的WLS上,所以默认的Configuration要选择AppModuleService,以及JDBC DataSource形式的数据库连接。


要事先在WLS Console中配置该DataSouce。


7. 访问EM,找到发布的应用,测试两个方法。
http://localhost:7001/Application7-Project1-context-root/AppModuleService?wsdl。
Project下载: AM_WebService.7z
参考文献:

1. http://andrejusb.blogspot.com/2009/08/web-service-interface-for-adf-bc.html。

http://maping930883.blogspot.com/2012/06/adf154amamwebservice.html

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读