如果现场使用SCE开发流程,并且平台是oracle数据库,或者用户提供第三方的oracle数据库,下文提供一种SCE通过oracle数据库调用webservice接口的方法:
以下是确认XDB是否已经安装:
oracle安装了XDB,如果没有安装,请按照如下步骤加载XDB(如果XDB已经安装,则忽略下面这4个系统脚本的加载步骤)
su - oracle
cd $ORACLE_HOME
cd rdbms/admin
sqlplus ' / as sysdba'@catqm.sql xdb XDB TEMP YES
第一个参数是 xdb 用户的密码
第二个参数是 xdb tablespace
第三个参数是temp tablespace
第四个参数是,如果是11.2以上的版本是YES,否则是NO
以上脚本加载完成后,依次再执行下面3个脚本:
@catnacl.sql
@dbmsnacl.sql
@prvtnacl.plb
以下是加载接口调用ACL权限并加载测试存储过程
XDB确认安装完成后,按以下步骤增加Web服务url给访问控制技术列表:
--创建访问控制列表writeCusScore.xml,writeCusScore.xml控制列表拥有connect权限,并把这个权限给了XXX用户 注意改为自己的用户
BEGIN
DBMS_NETWORK_ACL_ADMIN.CREATE_ACL(acl => 'writeCusScore.xml', --名字自己定义,和下面授权保持一致就行
description => 'Permissions to access the web service url', --描述
principal => 'XXX', --赋予权限给哪个用户
is_grant => TRUE, --true表示授予权限 false表示取消权限
privilege => 'connect');
COMMIT;
END;
--使用ADD_PRIVILEGE存储过程将其他的用户或角色添加到访问控制列表中,它的参数与CREATE_ACL存储过程的参数类似,
--省略了DESCRIPTION参数,同时增加了POSITION参数,它用于设置优先顺序。
BEGIN
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(acl => 'writeCusScore.xml',
principal => 'XXX',
is_grant => TRUE,
privilege => 'resolve',
position => null);
COMMIT;
END;
--使用ASSIGN_ACL存储过程给网络分配访问控制列表
BEGIN
DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(acl => 'writeCusScore.xml',
host => '*.huawei.com', -- 主机名,域名,ip地址或分配的子网,主机名大小写敏感,ip地址和域名允许使用通配符
--lower_port => 80,
upper_port => NULL);
COMMIT;
END;
执行完上面的语句后,使用下面语句查看时候增加成功:
--查询创建的ACL信息SELECT host,
lower_port,
upper_port,
acl,
DECODE(DBMS_NETWORK_ACL_ADMIN.CHECK_PRIVILEGE_ACLID(aclid,
'XXX',
'connect'),
1,
'GRANTED',
0,
'DENIED',
NULL) privilege
FROM dba_network_acls;
如果有记录则应该正常。
ACL权限加载完成后,使用XXX登录加载存储过程即可。
测试存储过程如下:
create or replace procedure p_test(t_calldata in varchar2,
ctCallId in varchar2,
srNo in varchar2,
callW3Account in varchar2,
agentId in varchar2,
agentId in varchar2,
ibegintime in varchar2,
iendtime in varchar2,
iuseroption in varchar2)
is
custcomment varchar2(2);
req utl_http.req;
res utl_http.resp;
url varchar2(4000) := 'http://test.huawei.com/icarecic/ivr/services/itr/tac/invoicecall/writeEvaluate';
buffer varchar2(4000);
content varchar2(4000);
begin
custcomment:=replace(iuseroption,' ','');
content := '{"requestParam":{"ctCallId":"' || ctCallId ||
'", "agentId":"' || agentId || '","srNo":"' || srNo ||
'","callW3Account":"' || callW3Account ||
'","custComment":"' || custcomment || '"}}';
req := utl_http.begin_request(url, 'POST', ' HTTP/1.1');
utl_http.set_header(req, 'user-agent', 'mozilla/4.0');
utl_http.set_header(req, 'content-type', 'application/json');
utl_http.set_header(req, 'Content-Length', length(content));
utl_http.write_text(req, content);
res := utl_http.get_response(req);
begin
loop
utl_http.read_line(res, buffer);
dbms_output.put_line(buffer);
end loop;
utl_http.end_response(res);
insert into t_satisfaction(begintime,endtime,ctcallid,agentid,srno,callw3account,custcomment,result) values(ibegintime,iendtime,ctcallid,agentid,srno,callw3account,custcomment,'1');
commit;
exception
when utl_http.end_of_body then
utl_http.end_response(res);
insert into t_satisfaction(begintime,endtime,ctcallid,agentid,srno,callw3account,custcomment,result) values(ibegintime,iendtime,ctcallid,agentid,srno,callw3account,custcomment,'2');
commit;
end;
end p_test;
存储过程建完后,SCE流程就可以通过APLOGIC调用这个存储过程来实现对webservice接口的调用了,哈哈哈