oracle 在apex中调用碧玉报告时出错,也创建了acl,但仍然给出acl错误

emeijp43  于 2023-06-22  发布在  Oracle
关注(0)|答案(1)|浏览(105)

我做了这篇文章中的一切:
https://pretius.com/blog/jaspersoft-apex-integration
但是在运行时,我遇到了一个acl错误,即使我创建了一个acl,它仍然给我同样的错误,我该怎么办?
我使用Oracle 11 g、Apex 21、Tomcat 9和碧玉Server 7.5。
这段代码在apex中使用:

DECLARE
  v_blob                 BLOB;
  v_file_type            VARCHAR2 (25) :='pdf';
  v_file_name            VARCHAR2 (25) := 'employee.'||v_file_type;
  v_vcContentDisposition VARCHAR2 (25)  := 'inline';
  v_DEPTNO               NUMBER := :P10_DEPTNO;
  v_hostname   VARCHAR2(30) := 'localhost'; -- your hostname, eg: localhost
  v_port       NUMBER       := '5080'; -- port for your JasperReports Server, eg: 8081
  v_username   VARCHAR2(50) := 'anonymousUser'; -- jasperreports server username 
  v_password   VARCHAR2(50) := 'anonymousUser'; -- jaspereports server password
  v_jasper_string VARCHAR2(30) := v_username || ';' || v_password;
  v_login_url  VARCHAR2(100) := 'http://' || v_hostname || ':' || v_port || '/jasperserver/rest/login';
  v_report_url VARCHAR2(100) := 'http://' || v_hostname || ':' || v_port || '/jasperserver/rest_v2/reports/reports/' || v_file_name;
BEGIN
  -- log into jasper server
  v_blob := apex_web_service.make_rest_request_b(
    p_url => v_login_url,
    p_http_method => 'GET',
    p_parm_name => apex_util.string_to_table('j_username;j_password',';'),
    p_parm_value => apex_util.string_to_table(v_jasper_string,';')
  );
  -- download file
  v_blob := apex_web_service.make_rest_request_b(
    p_url => v_report_url,
    p_http_method => 'GET',
    p_parm_name => apex_util.string_to_table('p_dept',';'),
    p_parm_value => apex_util.string_to_table(v_DEPTNO,';')
  );
  --OWA_UTIL.mime_header ('application/pdf', FALSE);  -- view your pdf file
  OWA_UTIL.MIME_HEADER( 'application/octet', FALSE ); -- download your pdf file
  HTP.p('Content-Length: ' || DBMS_LOB.GETLENGTH(v_blob));
  HTP.p('Content-Disposition: ' || v_vcContentDisposition ||'; filename="' || v_file_name || '"');
  OWA_UTIL.http_header_close;
  WPG_DOCLOAD.DOWNLOAD_FILE(v_blob);
  APEX_APPLICATION.STOP_APEX_ENGINE;

END;

这个错误:
出现1个错误ORA-29273:HTTP请求失败ORA-06512:在“SYS.UTL_HTTP”,第1339行ORA-29261:错误参数ORA-06512:在“APEX_200100.WWV_FLOW_WEB_SERVICES”,第1284行ORA-29273:HTTP请求失败ORA-06512:在“SYS.UTL_HTTP”,第1130行ORA-24247:访问控制列表(ACL)拒绝网络访问
谢谢你帮我

hlswsv35

hlswsv351#

你可以从下面的博客得到答案。,https://forums.oracle.com/ords/apexds/post/jasper-server-and-apex-integration-getting-ora-06512-9129'

And., I got success by this below code
 g_user_agent VARCHAR2(255) := 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/A.B (KHTML, like Gecko) Chrome/X.Y.Z.W Safari/A.B.';
    v_url          varchar2(4000);
    v_request      sys.utl_http.req;
    v_response      sys.utl_http.resp;
    v_file          blob;
    v_download      raw(32767);
    v_mime_header  varchar2(64) ;
    nm  owa.vc_arr;
    vl  owa.vc_arr;

BEGIN
    -- init the cgi environment
    nm(1) := 'DUMMY_JUST_TO_SET_UP_OWA_UTIL';
    vl(1) := 'WHATEVER';
    owa.init_cgi_env( nm.count, nm, vl );

    v_url := 'http://myUser:myPwd@myHost:myPort/jasperserver/rest_v2/reports/'||p_report_name||'?'||p_parameter; 

    v_request := sys.utl_http.begin_request(v_url);
    sys.utl_http.set_header(v_request, 'User-Agent', g_user_agent);
    v_response := sys.utl_http.get_response(v_request); 

    dbms_lob.createtemporary(v_file, TRUE, dbms_lob.session); 

    LOOP
    BEGIN
      sys.utl_http.read_raw(v_response, v_download);
      dbms_lob.writeappend(v_file, utl_raw.length(v_download), v_download);
      EXCEPTION WHEN sys.utl_http.end_of_body THEN
        EXIT;
      END;
    END LOOP; 

    sys.utl_http.end_response(v_response);

    owa_util.mime_header('application/' || nvl(p_output_format,'octet'), false);
    htp.p('Content-length: ' || dbms_lob.getlength(v_file));
    htp.p('Content-Disposition: inline; filename="' || p_report_name || '.'|| p_output_format ||'"');
    owa_util.http_header_close;

    wpg_docload.download_file(v_file); 

    dbms_lob.freetemporary(v_file);


Please refer https://www.eehelp.com/question/download-jasperserver-for-apex/

相关问题