当前位置:   article > 正文

Oracle EBS 通过PLSQL Package 方式发布WebService_ebs web service接口开发

ebs web service接口开发

1.PLSQL中新建包说明:cux_wz_connect_pkg

  1. CREATE OR REPLACE PACKAGE cux_wz_connect_pkg AS
  2. /* $Header: $ */
  3. /*#
  4. * cux wz interface Use to test Connection
  5. * @rep:scope public
  6. * @rep:product cux
  7. * @rep:lifecycle active
  8. * @rep:displayname CUX WZ Soa Connect Interface
  9. * @rep:compatibility S
  10. * @rep:category BUSINESS_ENTITY CUX_SERVICE
  11. */
  12. /*#
  13. * Get Connection flag
  14. * @param p_value Post value
  15. * @param x_flag Respons
  16. * @rep:scope public
  17. * @rep:lifecycle active
  18. * @rep:displayname Get Connection flag
  19. * @rep:compatibility S
  20. */
  21. PROCEDURE get_connect_flag(p_value IN VARCHAR2, x_flag OUT VARCHAR2);
  22. 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

  1. CREATE OR REPLACE PACKAGE BODY cux_wz_connect_pkg IS
  2. /*==================================================
  3. Copyright (C) Hand Enterprise Solutions Co.,Ltd.
  4. AllRights Reserved
  5. ==================================================*/
  6. /*==================================================
  7. Program Name:
  8. cux_wz_connect_pkg
  9. Description:
  10. 与分宜智能电厂WebService接口之心跳接口,此接口用来测试分宜智能电厂一体化平台的接口与EBS是否连通
  11. History:
  12. 1.00 2020-06-19 hao.feng Creation
  13. ==================================================*/
  14. /*==================================================
  15. Procedure/Function Name :
  16. get_connect_flag
  17. Description:
  18. 心跳接口主程序
  19. Argument:
  20. p_value :分宜智能电厂一体化平台传递值
  21. x_flag :将p_value返回去
  22. Return:
  23. History:
  24. 1.00 2020-06-19 hao.feng Creation
  25. ==================================================*/
  26. PROCEDURE get_connect_flag(p_value IN VARCHAR2, x_flag OUT VARCHAR2) IS
  27. BEGIN
  28. x_flag := p_value;
  29. EXCEPTION
  30. WHEN OTHERS THEN
  31. x_flag := NULL;
  32. END get_connect_flag;
  33. 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测试都可以

  1. <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">
  2. <soap:Header xmlns:ns1="http://xmlns.oracle.com/apps/cux/soaprovider/plsql/cux_wz_connect_pkg/">
  3. <ns1:SOAHeader>
  4. <ns1:Responsibility>SYSTEM_ADMINISTRATOR</ns1:Responsibility>
  5. <ns1:RespApplication>SYSADMIN</ns1:RespApplication>
  6. <ns1:SecurityGroup>STANDARD</ns1:SecurityGroup>
  7. <ns1:NLSLanguage>AMERICAN</ns1:NLSLanguage>
  8. <ns1:Org_Id>100</ns1:Org_Id>
  9. </ns1:SOAHeader>
  10. <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>
  11. <soap:Body xmlns:ns2="http://xmlns.oracle.com/apps/cux/soaprovider/plsql/cux_wz_connect_pkg/get_connect_flag/">
  12. <ns2:InputParameters>
  13. <ns2:P_VALUE>test-connect</ns2:P_VALUE>
  14. </ns2:InputParameters>
  15. </soap:Body>
  16. </soap:Envelope>

 PLSQL测试脚本:

  1. DECLARE
  2. p_wsdl_url VARCHAR2(100) := 'http://xxx.xxx.cn:xxxx/webservices/SOAProvider/plsql/cux_wz_connect_pkg/?wsdl';
  3. p_http_request CLOB;
  4. p_http_response CLOB;
  5. x_return_status VARCHAR2(100);
  6. x_return_message VARCHAR2(2000);
  7. http_req utl_http.req;
  8. http_resp utl_http.resp;
  9. l_pos NUMBER := 1;
  10. l_leng NUMBER := 0;
  11. TYPE rec_req IS RECORD(
  12. p_req VARCHAR2(4000));
  13. TYPE rec_req_array IS TABLE OF rec_req INDEX BY BINARY_INTEGER;
  14. l_res_line VARCHAR2(32767);
  15. l_req_array rec_req_array;
  16. l_end_flag VARCHAR2(1);
  17. BEGIN
  18. 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">'||
  19. '<soap:Header xmlns:ns1="http://xmlns.oracle.com/apps/cux/soaprovider/plsql/cux_wz_connect_pkg/">
  20. <ns1:SOAHeader>
  21. <ns1:Responsibility>SYSTEM_ADMINISTRATOR</ns1:Responsibility>
  22. <ns1:RespApplication>SYSADMIN</ns1:RespApplication>
  23. <ns1:SecurityGroup>STANDARD</ns1:SecurityGroup>
  24. <ns1:NLSLanguage>AMERICAN</ns1:NLSLanguage>
  25. <ns1:Org_Id>101</ns1:Org_Id>
  26. </ns1:SOAHeader>
  27. <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>
  28. <soap:Body xmlns:ns2="http://xmlns.oracle.com/apps/cux/soaprovider/plsql/cux_wz_connect_pkg/get_connect_flag/">
  29. <ns2:InputParameters>
  30. <ns2:P_VALUE>test-connect</ns2:P_VALUE>
  31. </ns2:InputParameters>
  32. </soap:Body>
  33. </soap:Envelope>';--请求报文
  34. --初始化返回状态
  35. x_return_status := fnd_api.g_ret_sts_success;
  36. --取请求clob长度
  37. FOR i IN 1 .. ceil(dbms_lob.getlength(p_http_request) / 2400) LOOP
  38. l_req_array(i).p_req := dbms_lob.substr(p_http_request, 2400, l_pos);
  39. l_pos := l_pos + 2400;
  40. l_leng := l_leng + lengthb(l_req_array(i).p_req);
  41. END LOOP;
  42. --开始请求
  43. http_req := utl_http.begin_request(p_wsdl_url, 'POST', 'HTTP/1.1');
  44. --中文
  45. utl_http.set_header(http_req, 'Content-Type', 'text/xml; charset=utf-8');
  46. --请求xml长度
  47. utl_http.set_header(http_req, 'Content-Length', l_leng);
  48. utl_http.set_header(http_req, 'SOAPAction', '');
  49. FOR i IN 1 .. ceil(dbms_lob.getlength(p_http_request) / 2400) LOOP
  50. utl_http.write_text(http_req, l_req_array(i).p_req);
  51. END LOOP;
  52. --请求响应结果
  53. http_resp := utl_http.get_response(http_req);
  54. --返回状态
  55. dbms_output.put_line('http_resp.status_code:' || to_char(http_resp.status_code));
  56. IF nvl(http_resp.status_code, -1) <> 200 THEN
  57. x_return_status := fnd_api.g_ret_sts_error;
  58. END IF;
  59. dbms_lob.createtemporary(p_http_response, FALSE);
  60. BEGIN
  61. LOOP
  62. l_res_line := NULL;
  63. utl_http.read_text(http_resp, l_res_line, 800);
  64. --如果响应状态为失败,那么将响应数据输出
  65. IF x_return_status = fnd_api.g_ret_sts_error THEN
  66. dbms_output.put_line(l_res_line);
  67. END IF;
  68. dbms_lob.writeappend(p_http_response, length(l_res_line), l_res_line);
  69. END LOOP;
  70. EXCEPTION
  71. WHEN utl_http.end_of_body THEN
  72. l_end_flag := 'Y';
  73. utl_http.end_response(http_resp);
  74. END;
  75. dbms_output.put_line(p_http_response);--打印返回报文
  76. --结束响应
  77. IF nvl(l_end_flag, 'N') <> 'Y' THEN
  78. utl_http.end_response(http_resp);
  79. END IF;
  80. EXCEPTION
  81. WHEN OTHERS THEN
  82. x_return_status := fnd_api.g_ret_sts_error;
  83. x_return_message := 'http dbws error:' || SQLERRM;
  84. dbms_output.put_line(x_return_message);
  85. END;

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/143190
推荐阅读
相关标签
  

闽ICP备14008679号