IGS_学习笔记04_IREP开发PLSQL API为客户化集合接口(案例)
2014-01-02 Created By BaoXinjian
一、摘要
在Oracle EBS二次开发中,PL/SQL程序是开发人员使用频率最高的开发语言,同时也是大家最容易掌握的工具之一了,
而我们也很希望将自己编写的PL/SQL程 序发布为Web服务来提供给客户端程序使用,
同时也可以实现和外围系统的集成,有了irep_parser这个工具,我们就可以将自己编写的PL/SQL 程序发布到Oracle Integration Repositoy中。
Oracle Integration Repositoy中集成接口的来源都是Oracle,客户化的程序发布上去的为Custom。
二、添加客户化应用到Product Family
客户化应用设置好之后,它没有归属于任何的产品家族,如我的客户化应用BXJ,因此发布在客户化应用下的集成接口在Oracle Integration Repositoy中无法方便的查看,如下图:
如果客户化集成接口是组织到自己的应用下就需要先注册一个产品家族,下面将bAOxINJIAN University(BXJ) 应用注册到Oracle Seeker Suite(os_pf)这个产品家族下作为例子进行演示:
1. 添加产品家族 Oracle BaoXinjian Suite(bxj_pf)
BEGIN
-- Call the procedure
AD_PA_INSERT_PACKAGE.INSERT_AD_PM_PRODUCT_INFO(X_PRODUCT_ABBREVIATION => 'bxj_pf',
X_PSEUDO_PRODUCT_FLAG => 'N',
X_PRODUCT_FAMILY_FLAG => 'Y',
X_APPLICATION_SHORT_NAME => NULL,
X_PRODUCT_NAME => 'Gavin Custom Application Product Family',
X_PRODUCT_FAMILY_ABBREVIATION => NULL,
X_PRODUCT_FAMILY_NAME => NULL,
X_ARU_UPDATE_DATE => to_char(SYSDATE,'yyyy-mm-dd hh24:mi:ss'),
X_CURRDATE => to_char(SYSDATE,'yyyy-mm-dd hh24:mi:ss'),
X_LAST_UPDATED_BY => -1,
X_CREATED_BY => -1);
COMMIT;
DBMS_OUTPUT.PUT_LINE('Run Successfully');
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Run with error' || sqlcode || sqlerrm);
END;
2. 注册Baoxinjian University(bxj)应用到产品家族中
BEGIN
-- Call the procedure
AD_PA_INSERT_PACKAGE.INSERT_AD_PM_PRODUCT_INFO(X_PRODUCT_ABBREVIATION => 'bxj',
X_PSEUDO_PRODUCT_FLAG => 'N',
X_PRODUCT_FAMILY_FLAG => 'N',
X_APPLICATION_SHORT_NAME => 'BXJ',
X_PRODUCT_NAME => 'Gavin Custom Application',
X_PRODUCT_FAMILY_ABBREVIATION => NULL,
X_PRODUCT_FAMILY_NAME => NULL,
X_ARU_UPDATE_DATE => TO_CHAR(SYSDATE,'yyyy-mm-dd hh24:mi:ss'),
X_CURRDATE => TO_CHAR(SYSDATE,'yyyy-mm-dd hh24:mi:ss'),
X_LAST_UPDATED_BY => -1,
X_CREATED_BY => -1);
COMMIT;
DBMS_OUTPUT.PUT_LINE('Run Successfully');
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Run with error' || sqlcode || sqlerrm);
END;
3. 关联BaoXinjian University应用到产品家族Oracle BaoXinjian Suite下
BEGIN -- Call the procedure AD_PA_INSERT_PACKAGE.INSERT_AD_PM_PROD_FAMILY_MAP(X_PRODUCT_ABBREVIATION => 'bxj', X_PRODUCT_FAMILY_ABBREVIATION => 'bxj_pf', X_ARU_UPDATE_DATE => TO_CHAR(SYSDATE, 'yyyy-mm-dd hh24:mi:ss'), X_CURRDATE => TO_CHAR(SYSDATE, 'yyyy-mm-dd hh24:mi:ss'), X_LAST_UPDATED_BY => -1, X_CREATED_BY => -1); COMMIT; DBMS_OUTPUT.PUT_LINE('Run Successfully'); EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('Run with error' || sqlcode || sqlerrm); END;
4. 完成后如果应用下有集成接口可以看到如下的产品家族信息
三、按照集成接口标记规范编写PL/SQL程序
按照业务逻辑的要求编写PL/SQL程序,除了需要在PL/SQL程序的声明中按照集成接口标记的要求添加标记注释之外,其它和一般的程序没有任何区别,如下是一个用来实现新增一个员工的程序:
关键几个标记描述:
@rep:product => BXJ 代表集成接口注册到XHU应用中,必须是系统中存在的应用简称
@rep:displayname => OracleBXJ Employee 集成接口的名称
@param => 存储过程和方法的参数,都需要标注出来供调用服务的客户端查看
@rep:category => BUSINESS_ENTITY ORACLEBXJ 业务实体的类型,ORACLEBXJ必须在BUSINESS_ENTITY 值列表类型下定义存在,否则无法通过验证
1. 注册Bussiness Entity
2. 创建测试表
CREATE TABLE bxj_employees
(
empno VARCHAR2 (50),
ename VARCHAR2 (50),
job VARCHAR2 (50),
mgr NUMBER,
hiredate DATE,
sal NUMBER,
comm NUMBER,
deptno NUMBER
)
3. 创建测试Employee包Header
CREATE OR REPLACE PACKAGE oraclebxj_emp_pkg AS
/* $Header: $ */
/*#
* This package using create the item information
* @rep:scope public
* @rep:product BXJ
* @rep:lifecycle active
* @rep:displayname Gavin Item Maintainance Service
* @rep:compatibility S
* @rep:category BUSINESS_ENTITY BXJ_BUSINESS_ENTITY
*/
/*#
* Create an Employee
* @param p_empno employee number
* @param p_ename employee name
* @param p_job employee's job
* @param p_mgr employee's manager
* @param p_hiredate employee is hired date
* @param p_sal employee's salary
* @param p_comm employee's commision
* @param p_deptno employee's department
* @rep:scope public
* @rep:lifecycle active
* @rep:displayname Create an Employee
*/
PROCEDURE create_employee(p_empno VARCHAR2,
p_ename VARCHAR2,
p_job VARCHAR2,
p_mgr NUMBER,
p_hiredate DATE,
p_sal NUMBER,
p_comm NUMBER,
p_deptno NUMBER);
END oraclebxj_emp_pkg;
4. 创建测试Employee包Header
CREATE OR REPLACE PACKAGE BODY oraclebxj_emp_pkg AS
/* $Header: $ */
/*#
* This package using create the item information
* @rep:scope public
* @rep:product BXJ
* @rep:lifecycle active
* @rep:displayname Gavin Item Maintainance Service
* @rep:compatibility S
* @rep:category BUSINESS_ENTITY BXJ_BUSINESS_ENTITY
*/
/*#
* Create an Employee
* @param p_empno employee number
* @param p_ename employee name
* @param p_job employee's job
* @param p_mgr employee's manager
* @param p_hiredate employee is hired date
* @param p_sal employee's salary
* @param p_comm employee's commision
* @param p_deptno employee's department
* @rep:scope public
* @rep:lifecycle active
* @rep:displayname Create an Employee
*/
PROCEDURE create_employee(p_empno VARCHAR2,
p_ename VARCHAR2,
p_job VARCHAR2,
p_mgr NUMBER,
p_hiredate DATE,
p_sal NUMBER,
p_comm NUMBER,
p_deptno NUMBER) IS
BEGIN
INSERT INTO bxj_employees
VALUES
(p_empno, p_ename, p_job, p_mgr, p_hiredate, p_sal, p_comm, p_deptno);
COMMIT;
END;
END oraclebxj_emp_pkg;
四、验证集成接口标记并生成iLDT文件
将编写好的PLSQL声明定义保存为.pls文件(oraclebxj_emp_pkg.pls),并将其上传到服务器应用(sqlap)的patch/115/sql目录下,
通过Telnet使用命令来验证和生成集成接口标记文件,成功验证后会有如下的日志生成,同时会生成iLDT文件oraclebxj_emp_pkg_pls.ildt ,如果标记存在问题会打印出对应的错误信息,需要注意查看错误消息并进行修正。
[applvis@paleonode1 sql]$ pwd
/u2/VIS/visappl/apps/apps_st/appl/ap/12.0.0/patch/115/sql
[applvis@paleonode1 sql]$ ls oraclebxj_emp_pkg*
oraclebxj_emp_pkg.pls
[applvis@paleonode1 sql]$ $IAS_ORACLE_HOME/perl/bin/perl $FND_TOP/bin/irep_parser.pl -g -v -username=sysadmin sqlap:patch/115/sql:oraclebxj_emp_pkg.pls:12.0=oraclebxj_emp_pkg.pls
# Interface Repository Annotation Processor, 12.0.0
#
# Generating annotation output.
# Processing file 'oraclebxj_emp_pkg.pls'.
# Using YAPP-based parser.
# Found a package-level annotation for 'ORACLEBXJ_EMP_PKG'.
# Found a detail-level annotation...
# Found a procedure named 'CREATE_EMPLOYEE'.
# Done all files.
五、将iLDT文件上传到Oracle Integration Repositoy中
将上面生成的iLDT文件通过FNDLOAD命令工具上传到Oracle Integration Repositoy中,命令如下:
FNDLOAD apps/apps 0 Y UPLOAD $FND_TOP/patch/115/import/wfirep.lct oraclebxj_emp_pkg_pls.ildt
[applvis@paleonode1 sql]$ pwd
/u2/VIS/visappl/apps/apps_st/appl/ap/12.0.0/patch/115/sql
[applvis@paleonode1 sql]$ ls *bxj*
oraclebxj_emp_pkg.pls oraclebxj_emp_pkg_pls.ildt
[applvis@paleonode1 sql]$ FNDLOAD apps/apps 0 Y UPLOAD $FND_TOP/patch/115/import/wfirep.lct oraclebxj_emp_pkg_pls.ildt
Log filename : L5814384.log
Report filename : O5814384.out
六、查看所发布的继承接口信息
1. ildt成功上传之后通过Oracle Integration Repositoy可以查看如下的集成接口信息
2. 下面是接口中的详细描述
3. 查看接口栏位介绍
4. 接口产生的WSDL描述如下
<?xml version="1.0" encoding="UTF-8"?> <definitions name="ORACLEBXJ_EMP_PKG" targetNamespace="http://xmlns.oracle.com/apps/bxj/soaprovider/plsql/oraclebxj_emp_pkg/" xmlns:tns="http://xmlns.oracle.com/apps/bxj/soaprovider/plsql/oraclebxj_emp_pkg/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns1="http://xmlns.oracle.com/apps/bxj/soaprovider/plsql/oraclebxj_emp_pkg/create_employee/"> <types> <schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://xmlns.oracle.com/apps/bxj/soaprovider/plsql/oraclebxj_emp_pkg/create_employee/"> <include schemaLocation="http://paleonode1.sh.paleotek.com:8002/webservices/SOAProvider/plsql/oraclebxj_emp_pkg/APPS_ORACLEBXJ_EMP_PKG_CREATE_EMPLOYEE.xsd"/> </schema> <schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://xmlns.oracle.com/apps/bxj/soaprovider/plsql/oraclebxj_emp_pkg/"> <element name="SOAHeader"> <complexType> <sequence> <element name="Responsibility" minOccurs="0" type="string"/> <element name="RespApplication" minOccurs="0" type="string"/> <element name="SecurityGroup" minOccurs="0" type="string"/> <element name="NLSLanguage" minOccurs="0" type="string"/> <element name="Org_Id" minOccurs="0" type="string"/> </sequence> </complexType> </element> </schema> </types> <message name="CREATE_EMPLOYEE_Input_Msg"> <part name="header" element="tns:SOAHeader"/> <part name="body" element="tns1:InputParameters"/> </message> <portType name="ORACLEBXJ_EMP_PKG_PortType"> <operation name="CREATE_EMPLOYEE"> <input message="tns:CREATE_EMPLOYEE_Input_Msg"/> </operation> </portType> <binding name="ORACLEBXJ_EMP_PKG_Binding" type="tns:ORACLEBXJ_EMP_PKG_PortType"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="CREATE_EMPLOYEE"> <soap:operation soapAction="http://paleonode1.sh.paleotek.com:8002/webservices/SOAProvider/plsql/oraclebxj_emp_pkg/"/> <input> <soap:header message="tns:CREATE_EMPLOYEE_Input_Msg" part="header" use="literal"/> <soap:body parts="body" use="literal"/> </input> </operation> </binding> <service name="ORACLEBXJ_EMP_PKG_Service"> <port name="ORACLEBXJ_EMP_PKG_Port" binding="tns:ORACLEBXJ_EMP_PKG_Binding"> <soap:address location="http://paleonode1.sh.paleotek.com:8002/webservices/SOAProvider/plsql/oraclebxj_emp_pkg/"/> </port> </service> </definitions>
Thanks and Regards
学习:张礼军先生 - http://oracleseeker.com/2009/10/21/publish_plsql_api_to_oracle_integration_repository/
技术交流,技术讨论,欢迎加入
Technology Blog Created By Oracle ERP - 鲍新建