Oracle EBS 通过PLSQL Package 方式发布WebService

1.PLSQL中新建包说明:cux_wz_connect_pkg

CREATE OR REPLACE PACKAGE cux_wz_connect_pkg AS
  /* $Header: $ */
  /*#
  * cux wz interface Use to test Connection
  * @rep:scope public
  * @rep:product cux
  * @rep:lifecycle active
  * @rep:displayname CUX WZ Soa Connect Interface
  * @rep:compatibility S
  * @rep:category BUSINESS_ENTITY CUX_SERVICE
  */
  /*#
  * Get Connection flag
  * @param p_value Post value
  * @param x_flag Respons
  * @rep:scope public
  * @rep:lifecycle active
  * @rep:displayname Get Connection flag
  * @rep:compatibility S
  */
  PROCEDURE get_connect_flag(p_value IN VARCHAR2, x_flag OUT VARCHAR2);
END cux_wz_connect_pkg;

以上注释中的内容分别对应:

* @rep:category BUSINESS_ENTITY CUX_SERVICE

此处可以在公用块码中搜索lookup_type“BUSINESS_ENTITY”,将对应的信息维护进去,此处就会显示为自定义的meaning

cux wz interface Use to test Connection : 

编译保存后,cux_wz_connect_pkg.spc另存为后缀名为pls的文件,或直接修改保存文件的后缀名为pls:cux_wz_connect_pkg.pls

2.PLSQL中新建包体:cux_wz_connect_pkg

CREATE OR REPLACE PACKAGE BODY cux_wz_connect_pkg IS
  /*==================================================
  Copyright (C) Hand Enterprise Solutions Co.,Ltd.
             AllRights Reserved
  ==================================================*/
  /*==================================================
  Program Name:
      cux_wz_connect_pkg
  Description:
      与分宜智能电厂WebService接口之心跳接口,此接口用来测试分宜智能电厂一体化平台的接口与EBS是否连通
  History:
      1.00  2020-06-19 hao.feng Creation
  ==================================================*/
  /*==================================================
  Procedure/Function Name :
      get_connect_flag
  Description:
      心跳接口主程序
  Argument:
      p_value         :分宜智能电厂一体化平台传递值
      x_flag          :将p_value返回去
  Return:
       
  History:
      1.00  2020-06-19 hao.feng Creation
  ==================================================*/
  PROCEDURE get_connect_flag(p_value IN VARCHAR2, x_flag OUT VARCHAR2)  IS
  
  BEGIN
    x_flag := p_value;
  EXCEPTION
    WHEN OTHERS THEN
      x_flag := NULL;
  END get_connect_flag;
END cux_wz_connect_pkg;

 编译保存后,cux_wz_connect_pkg.bdy另存为后缀名为plb的文件,或直接修改保存文件的后缀名为pls:cux_wz_connect_pkg.plb

3.将这两个文件上传到服务器上,路径如下:cd $CUX_TOP/patch/115/sql

4.登陆应用服务器命令窗口中:

先 cd $CUX_TOP/patch/115/sql

a.把文件.PLS文件上传到服务器,路径为:$CUX_TOP/patch/115/sql下。

b.使用工具登录应用服务器

c.执行以下命令生成.ildt文件.生成成功后检查是否有生成ildt文件。

$IAS_ORACLE_HOME/perl/bin/perl $FND_TOP/bin/irep_parser.pl -g -v -username=sysadmin cux:patch/115/sql:cux_wz_connect_pkg.pls:12.0.0=cux_wz_connect_pkg.pls

d.执行以下命令上传生成的.ildt文件。

FNDLOAD apps/appspassword 0 Y UPLOAD $FND_TOP/patch/115/import/wfirep.lct cux_wz_connect_pkg_pls.ildt

5. 使用sysadmin账户登录EBS,进入集成 SOA 网关-》集成信息库

点击生成WSDL,然后选择身份验证类型(此处具体看情况选择,一般选择用户名变量)再点击部署。如下图,这样web service 接口我们就部署完毕。

创建授权,点击创建授权把接口授权给需要使用接口的用户ASADMIN

6.查看wsdl,并且根据信息获取测试报文格式

如上例,WSDL是:

http://xxx.xxx.cn:xxxx/webservices/SOAProvider/plsql/cux_wz_connect_pkg/?wsdl

将后面的"?wsdl"去掉,保留"/",重新打开:

http://xxx.xxx.cn:xxxx/webservices/SOAProvider/plsql/cux_wz_connect_pkg/

显示网页:

 

 勾选WS-Security后面的Include In Header,编写信息如下:

点击XML源:

对于<ns1:SOAHeader>中的头4个子标签的信息:

Responsibility:

RespApplication:

后面两个写死即可<ns1:SecurityGroup>STANDARD</ns1:SecurityGroup>

            <ns1:NLSLanguage>AMERICAN</ns1:NLSLanguage>

将以上内容copy出来就可以测试了

不管是是用SOAPUI测试或者是用上面打开的网页测试,或者用PLSQL测试都可以

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
    <soap:Header xmlns:ns1="http://xmlns.oracle.com/apps/cux/soaprovider/plsql/cux_wz_connect_pkg/">
        <ns1:SOAHeader>
            <ns1:Responsibility>SYSTEM_ADMINISTRATOR</ns1:Responsibility>
            <ns1:RespApplication>SYSADMIN</ns1:RespApplication>
            <ns1:SecurityGroup>STANDARD</ns1:SecurityGroup>
            <ns1:NLSLanguage>AMERICAN</ns1:NLSLanguage>
            <ns1:Org_Id>100</ns1:Org_Id>
        </ns1:SOAHeader>
    <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" soap:mustUnderstand="1"><wsse:UsernameToken xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsse:Username>Username</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Password</wsse:Password></wsse:UsernameToken></wsse:Security></soap:Header>
    <soap:Body xmlns:ns2="http://xmlns.oracle.com/apps/cux/soaprovider/plsql/cux_wz_connect_pkg/get_connect_flag/">
        <ns2:InputParameters>
            <ns2:P_VALUE>test-connect</ns2:P_VALUE>
        </ns2:InputParameters>
    </soap:Body>
</soap:Envelope>

 PLSQL测试脚本:

DECLARE
  p_wsdl_url       VARCHAR2(100) :=   'http://xxx.xxx.cn:xxxx/webservices/SOAProvider/plsql/cux_wz_connect_pkg/?wsdl';
  p_http_request   CLOB;
  p_http_response  CLOB;
  x_return_status  VARCHAR2(100);
  x_return_message VARCHAR2(2000);
  http_req         utl_http.req;
  http_resp        utl_http.resp;
  l_pos            NUMBER := 1;
  l_leng           NUMBER := 0;
  TYPE rec_req IS RECORD(
    p_req VARCHAR2(4000));
  TYPE rec_req_array IS TABLE OF rec_req INDEX BY BINARY_INTEGER;
  l_res_line  VARCHAR2(32767);
  l_req_array rec_req_array;
  l_end_flag  VARCHAR2(1);
BEGIN
  p_http_request := '<soap:Envelope  xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"  xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">'||
                        '<soap:Header  xmlns:ns1="http://xmlns.oracle.com/apps/cux/soaprovider/plsql/cux_wz_connect_pkg/">
                            <ns1:SOAHeader>
                                 <ns1:Responsibility>SYSTEM_ADMINISTRATOR</ns1:Responsibility>
                                 <ns1:RespApplication>SYSADMIN</ns1:RespApplication>
                                <ns1:SecurityGroup>STANDARD</ns1:SecurityGroup>
                                <ns1:NLSLanguage>AMERICAN</ns1:NLSLanguage>
                                <ns1:Org_Id>101</ns1:Org_Id>
                            </ns1:SOAHeader>
                        <wsse:Security  xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"  xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"  soap:mustUnderstand="1"><wsse:UsernameToken  xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"  xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsse:Username>Username</wsse:Username><wsse:Password  Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Password</wsse:Password></wsse:UsernameToken></wsse:Security></soap:Header>
                        <soap:Body  xmlns:ns2="http://xmlns.oracle.com/apps/cux/soaprovider/plsql/cux_wz_connect_pkg/get_connect_flag/">
                            <ns2:InputParameters>
                                <ns2:P_VALUE>test-connect</ns2:P_VALUE>
                            </ns2:InputParameters>
                        </soap:Body>
                    </soap:Envelope>';--请求报文
  --初始化返回状态
  x_return_status := fnd_api.g_ret_sts_success;
  --取请求clob长度                   
  FOR i IN 1 .. ceil(dbms_lob.getlength(p_http_request) / 2400) LOOP
    l_req_array(i).p_req := dbms_lob.substr(p_http_request, 2400, l_pos);
  
    l_pos  := l_pos + 2400;
    l_leng := l_leng + lengthb(l_req_array(i).p_req);
  END LOOP;
  --开始请求
  http_req := utl_http.begin_request(p_wsdl_url, 'POST', 'HTTP/1.1');
  --中文
  utl_http.set_header(http_req, 'Content-Type', 'text/xml;   charset=utf-8');
  --请求xml长度
  utl_http.set_header(http_req, 'Content-Length', l_leng);
  utl_http.set_header(http_req, 'SOAPAction', '');
  FOR i IN 1 .. ceil(dbms_lob.getlength(p_http_request) / 2400) LOOP
    utl_http.write_text(http_req, l_req_array(i).p_req);
  END LOOP;
  --请求响应结果
  http_resp := utl_http.get_response(http_req);
  --返回状态
  dbms_output.put_line('http_resp.status_code:' ||   to_char(http_resp.status_code));
  IF nvl(http_resp.status_code, -1) <> 200 THEN
    x_return_status := fnd_api.g_ret_sts_error;
  END IF;
  dbms_lob.createtemporary(p_http_response, FALSE);
  BEGIN
    LOOP
      l_res_line := NULL;
      utl_http.read_text(http_resp, l_res_line, 800);
      --如果响应状态为失败,那么将响应数据输出
      IF x_return_status = fnd_api.g_ret_sts_error THEN
        dbms_output.put_line(l_res_line);
      END IF;
      dbms_lob.writeappend(p_http_response, length(l_res_line),   l_res_line);
    END LOOP;
  EXCEPTION
    WHEN utl_http.end_of_body THEN
      l_end_flag := 'Y';
      utl_http.end_response(http_resp);
  END;
  dbms_output.put_line(p_http_response);--打印返回报文
  --结束响应
  IF nvl(l_end_flag, 'N') <> 'Y' THEN
    utl_http.end_response(http_resp);
  END IF;
EXCEPTION
  WHEN OTHERS THEN
    x_return_status  := fnd_api.g_ret_sts_error;
    x_return_message := 'http dbws error:' || SQLERRM;
    dbms_output.put_line(x_return_message);
END;

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

仨告

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值