使用集成SOA网关的PL / SQL中的REST
Oracle电子商务套件集成SOA网关(ISG)是一款开箱即用的模块,支持在Oracle Integration Repository中发布支持的接口类型。这些接口可以转换为SOAP和REST Web服务。请参阅metalink笔记号(文档ID 1311068.1):在版本12.2中安装Oracle电子商务套件集成SOA网关
高级配置步骤:
1)Enabling ASADMIN User with the Integration Administrator Role (ASADMIN should be active user and with complex password and should have UMX|FND_IREP_ADMIN role.)
2)Create a folder called ISG_TEMP in Oracle E-Business Suite. This folder should have write permission.
3)In the $INST_TOPsoa folder, update ISG_TEMP_DIRECTORY_LOCATION property in the isgagent.properties file as follow:<SID>.ISG_TEMP_DIRECTORY_LOCATION=<ISG_TEMP>
4)Run the txkISGConfigurator.xml utility with “ebsSetup” argument. The script will stop and restart the servers.
ant -f $JAVA_TOP/oracle/apps/fnd/txk/util/txkISGConfigurator.xml ebsSetup -DforceStop=yes
The following prompts appear:
•Enter the password for user APPS:
•Enter the ASADMIN user name : [ASADMIN]
•Enter the password for user ASADMIN :
•The script will forcefully stop the Oracle WebLogic Server now. Do you want to proceed (yes/no)? (yes, no)
Enter yes to stop the server. The script will stop the server and then restart the server.
The above script creates and deploys the data source "OAEADatasource" on Oracle E-Business Suite WebLogic Admin server and 'oafm_cluster1' server. It also creates the Authentication Provider "IsgAuthenticator" to be used by the REST services and stops the Weblogic Admin Server after accepting a confirmation from the user.
Note that apart from ISG, the data source "OAEADatasource" is used by other Oracle E-Business Suite edge applications. You will have to size up the data source connection pool accordingly. If the data source "OAEADatasource" is already created, use the -DforceDataSourceExists=true option to replace the existing data source. To proceed the setup without re-creating or overwriting the data source, use the option -DignoreDataSourceExists=true.
Use the option -DforceAuthenticationProviderExists=true to re-create the Authentication Provider.
5.Execute adop phase=fs_clone on Oracle E-Business Suite 12.2 enabled for Online Patching to copy the REST configurations done above to the other file system
6.Add directory $FND_TOP/perl to environment variable PERL5LIB
7.Download patch 13602850 and install this patch for perl library extensions. Patch archive p13602850_R12_GENERIC.zip contains following directories
a) Class-MethodMaker-1.12 b) Compress-Raw-Zlib-2.009 c) Compress-Zlib-2.009
cd <<above listed directory>>
and perform - perl Makefile.PL | make |make install
repeat this step to install all 3 perl modules
使用Oracle电子商务套件集成的SOA网关脚本验证REST服务安装
Execute the following script to validate the Oracle E-Business Suite Integrated SOA Gateway setup for REST services:
For example, use the following script to deploy a PL/SQL interface FND_USER_PKG as a REST service with POST method:
ant -f $JAVA_TOP/oracle/apps/fnd/isg/ant/isgDesigner.xml -Dactions=deploy -DserviceType=REST -DirepNames=FND_USER_PKG[{TESTUSERNAME:SYNC:POST}] -Dverbose=ON -Dalias=FndUserPkgSvc
创建自定义数据库对象(PL / SQL):
- 现在,在这一步中,我将解释如何在Integration Repository中注册自定义PL / SQL API,并创建REST Web服务。
例如:如果您将用户标识作为参数传递,以下PL / SQL程序包将返回应用程序用户名和电子邮件地址。
创建一个像这样的包规范(文件名xxfndus.pls),它应该有解析器所需的irep注释。
set verify off
whenever sqlerror exit failure rollback;
WHENEVER OSERROR EXIT FAILURE ROLLBACK;
CREATE OR REPLACE PACKAGE XXFND_USER_QUERY AS
/* $Header: xxfndus.pls $ */
/*#
* This custom PL/SQL package can be used fetch user details.
* @rep:scope public
* @rep:product FND
* @rep:displayname User Information query
* @rep:category BUSINESS_ENTITY XXFND_USER_Q
*/
PROCEDURE main_proc(
p_user_id IN number
,v_name OUT VARCHAR2
,v_email OUT VARCHAR2
,v_msg OUT VARCHAR2
,v_status OUT VARCHAR2)
/*#
* Use this procedure to fetch user information
* @param P_USER_ID is the user_id of the user
* @param V_NAME Returns user name by the program
* @param V_EMAIL Returns user email by the program
* @param V_MSG Returns messages by the program
* @param V_STATUS Returns status of the Program
* @rep:displayname User Information query
* @rep:category BUSINESS_ENTITY XXFND_USER_Q
* @rep:scope public
* @rep:lifecycle active
*/
;
END XXFND_USER_QUERY;
/
commit;
exit;
现在创建一个像这样的包体(文件名xxfndub.pls),包体不需要注释。
CREATE OR REPLACE PACKAGE BODY XXFND_USER_QUERY AS
PROCEDURE main_proc
(p_user_id NUMBER
,v_name OUT VARCHAR2
,v_email OUT VARCHAR2
,v_msg OUT VARCHAR2
,v_status OUT VARCHAR2)
AS
BEGIN
SELECT USER_NAME , EMAIL_ADDRESS
INTO v_name,v_email
FROM FND_USER
WHERE user_id = p_user_id;
v_msg := 'Successfully completed';
v_status := 'S';
EXCEPTION
WHEN OTHERS THEN
v_msg := 'Completed with Error' ;
v_status := 'F';
END main_proc;
END XXFND_USER_QUERY;
/
现在编译应用程序中的package spec&body
现在执行这个perl命令来进行irep解析
$IAS_ORACLE_HOME/perl/bin/perl $FND_TOP/bin/irep_parser.pl -g -v -username=sysadmin fnd:/patch/115/sql:xxfndus.pls:12.0=xxfndus.pls
这将生成一个名为xxfndus_pls.ildt的ildt文件。
现在执行以下FNDLOAD命令将ildt文件上传到IREP
$FND_TOP/bin/FNDLOAD apps/apps 0 Y UPLOAD $FND_TOP/patch/115/import/wfirep.lct xxfndus_pls.ildt
- 现在连接EBS并在Integration Repository中搜索XXFND_USER_QUERY作为内部名称。
- 单击服务并通过单击部署按钮为此内部PL / SQL API创建REST Web服务。
- 一旦部署REST服务,查看生成的WADL链接
- 同时请给予应用程序用户在ISG中新注册的Web服务的授权。
现在在SOAPUI或Chrome ARC中使用以下有效负载测试webservice
web service url: http://host.domain:port/webservices/rest/xxfnd1/main_proc/
Method: Post
Http request header parameters:
Content-Type: application/json
Accept: application/json
Authorization: Basic QVNBRE1JTjpNMGdlcm11bHVr
Content-Language: en-US
Payload Json:
{
"ISGServiceFault" : {
"Code" : "ISG_SERVICE_AUTH_FAILURE",
"Message" : "User is not authorized to execute the service",
"Resolution" : "Please check whether the user has the requisite grants.",
"ServiceDetails" : {
"ServiceName" : "xxfnd1",
"OperationName" : "main_proc",
"InstanceId" : "0"
}}}
出JSON是以下
{
"OutputParameters": {
"@xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
"@xmlns": "http://xmlns.oracle.com/apps/fnd/rest/xxfnd1/main_proc/",
"V_NAME": "SYSADMIN",
"V_EMAIL": {...},
"V_MSG": "Successfully completed",
"V_STATUS": "S"
}}
ISG REST Service Invocations中的常见错误有: -
策略要求身份验证令牌
原因:当安全头中的Web Service安全用户名令牌缺失或无效时,服务器将引发此错误。
解决方案:在安全性标头中传递有效的Web服务安全用户名令牌。
安全令牌无法通过身份验证或授权
原因:当Web服务安全用户名令牌中的用户名或(/和)密码无效时,服务器将引发此错误。
解决方案:在Web服务安全用户名令牌中传递有效的Oracle应用程序用户名和密码。
用户无权执行服务
原因:Web服务安全用户名令牌未授权执行在SOAP请求中调用的Web服务功能时,服务器将引发此错误。
解决方案:从Integration Repository UI在用户,角色或全局级别创建授权,以授权用户执行Web Service功能。从功能管理员职责清除缓存。
服务器故障:责任键无效
原因:在责任关键字在标题中的责任标题中传递无效时,服务器将引发此错误。
解决方案:服务器希望标题中的责任标题中包含有效的责任关键字。
使用此查询为特定用户查找有效的责任关键字: -
Select resp.RESPONSIBILITY_KEY, grp.SECURITY_GROUP_KEY,
APP.APPLICATION_SHORT_NAME
From FND_USER_RESP_GROUPS furg, FND_USER usr, fnd_responsibility_vl
resp,FND_SECURITY_GROUPS grp,FND_APPLICATION APP
where furg.user_id=usr.user_id
and furg.RESPONSIBILITY_ID=resp.RESPONSIBILITY_ID
and furg.SECURITY_GROUP_ID=grp.SECURITY_GROUP_ID
and furg.RESPONSIBILITY_APPLICATION_ID=APP.APPLICATION_ID
and usr.user_name= :username
责任申请短名称无效。
原因:服务器在报头中的RespApplication标题中的应用短名称无效时抛出此错误。
解决方案:服务器希望在Header中的RespApplication标题中使用有效的应用程序短名称。使用上面给出的查询来查找有效的应用程序短名称。
安全组密钥无效。
原因:当标题中的安全组标题中的安全组密钥无效时,服务器将引发此错误。
解决方案:服务器希望在标题中的SecurityGroup标题中使用有效的安全组密钥。使用上面给出的查询来查找有效的安全组密钥。
NLS语言无效。
原因:当标题中的NLS语言标题中的NLS语言无效时,服务器将引发此错误。
解决方法:服务器在标题中的NLSLanguage标题中预期有效的NLSLanguage值。使用以下查询来查找有效的NLSLanguage:
SELECT NLS_LANGUAGE FROM FND_LANGUAGES WHERE INSTALLED_FLAG in (‘B’,’I’);
服务未部署。
原因:当调用服务生成但未部署时,服务器会抛出此错误。
解决方案:从Integration Repository UI部署此服务。