{"id":19397,"date":"2018-04-15T17:45:35","date_gmt":"2018-04-15T15:45:35","guid":{"rendered":"https:\/\/pitss.org\/de\/?p=19397"},"modified":"2018-04-17T14:24:09","modified_gmt":"2018-04-17T12:24:09","slug":"jasper-reports-javascript-pl-sql-integration","status":"publish","type":"post","link":"https:\/\/pitss.org\/de\/jasper-reports-javascript-pl-sql-integration\/","title":{"rendered":"Jasper Reports &#8211; Javascript &#038; PL\/SQL Integration"},"content":{"rendered":"<p>[et_pb_section bb_built=&#8220;1&#8243; fullwidth=&#8220;on&#8220; _builder_version=&#8220;3.0.74&#8243; background_image=&#8220;https:\/\/pitss.org\/de\/wp-content\/uploads\/sites\/9\/2017\/08\/blog-2-header-v3-min.jpg&#8220; next_background_color=&#8220;#000000&#8243;][et_pb_fullwidth_header title=&#8220;PITSS Tech Blog&#8220; subhead=&#8220;News zu Java, PL\/SQL, Entwicklung &amp; Technologiewechsel&#8220; background_layout=&#8220;dark&#8220; text_orientation=&#8220;center&#8220; background_overlay_color=&#8220;rgba(0,0,0,0.53)&#8220; _builder_version=&#8220;3.0.74&#8243; title_font_size=&#8220;36px&#8220; subhead_font_size=&#8220;22px&#8220; max_width_tablet=&#8220;50px&#8220;]<\/p>\n<p>&nbsp;<\/p>\n<p>[\/et_pb_fullwidth_header][\/et_pb_section][et_pb_section bb_built=&#8220;1&#8243; specialty=&#8220;on&#8220; background_position_1=&#8220;top_left&#8220; background_position_2=&#8220;top_left&#8220; background_repeat_1=&#8220;no-repeat&#8220; background_repeat_2=&#8220;no-repeat&#8220; _builder_version=&#8220;3.0.69&#8243; prev_background_color=&#8220;#000000&#8243; next_background_color=&#8220;#000000&#8243;][et_pb_column type=&#8220;3_4&#8243; specialty_columns=&#8220;3&#8243;][et_pb_row_inner admin_label=&#8220;Row&#8220; custom_padding=&#8220;29.6833px|0px|0|0px&#8220; _builder_version=&#8220;3.0.69&#8243;][et_pb_column_inner type=&#8220;4_4&#8243; saved_specialty_column_type=&#8220;3_4&#8243;][et_pb_text _builder_version=&#8220;3.0.106&#8243; module_alignment=&#8220;left&#8220; background_layout=&#8220;light&#8220;]<\/p>\n<h1>Jasper Reports &#8211; Javascript &#038; PL\/SQL Integration<\/h1>\n<p>&nbsp;<\/p>\n<p>[\/et_pb_text][et_pb_team_member _builder_version=&#8220;3.0.106&#8243; name=&#8220;by Daniel Kampf&#8220; position=&#8220;Senior Consultant, PITSS GmbH&#8220; twitter_url=&#8220;https:\/\/twitter.com\/kampfda&#8220; image_url=&#8220;https:\/\/pitss.org\/de\/wp-content\/uploads\/sites\/9\/2018\/04\/daniel-kampf_.jpg.png&#8220; background_layout=&#8220;light&#8220; header_font_size=&#8220;16&#8243; max_width=&#8220;50%&#8220; \/][et_pb_text _builder_version=&#8220;3.0.106&#8243; module_alignment=&#8220;left&#8220; background_layout=&#8220;light&#8220;]<\/p>\n<p>In the last couple of months there has been a lot of information on how to migrate Oracle Reports to other modern reporting tools. For me, as I am dealing mostly with Jasper Reports, the question came up on how we actually can integrate Jasper Reports in Oracle Forms or other tools. So after a workshop together with TIBCO I started to look into the implementation options that the Community and Pro editions have. I had a look at two options: Visualize.js (part of the Jasper Reports Pro Edition) and the REST API (part of both editions).<\/p>\n<h2>Visualize.js<\/h2>\n<p>Visualize.js is a Javascript API framework that is part of the Pro edition of Jasper Reports. It gives you the possibility to embed Jasper Reports into web applications. Besides the possibility of integration of &#8222;simple reporting&#8220;, it is possible to &#8222;embed interactive HTML5 visualizations, dashboards or multi-element reports using standard JavaScript&#8220;.\u00a0 Oracle Forms in the latest version (currently 12.2.1.3) is able to integrate JavaScript also in environments that use the <a href=\"http:\/\/www.oracle.com\/technetwork\/developer-tools\/forms\/documentation\/oracleforms-12210-newfeatures-2906037.pdf\">Webstart and Standalone Launcher<\/a>. With that information it should be possible to call visualize.js from Oracle Forms or any other web application supporting JavaScript, and integrate Jasper Reports from that. In my little test scenario I was able to integrate a Jasper report from the server really quick. My next try is going to be to integrate a report or even reporting dashboard from Oracle Forms via Jetty.<\/p>\n<p>[\/et_pb_text][et_pb_image src=&#8220;https:\/\/pitss.org\/de\/wp-content\/uploads\/sites\/9\/2018\/04\/Unbenannt.gif&#8220; _builder_version=&#8220;3.0.106&#8243; show_in_lightbox=&#8220;on&#8220; url_new_window=&#8220;off&#8220; use_overlay=&#8220;off&#8220; always_center_on_mobile=&#8220;on&#8220; force_fullwidth=&#8220;off&#8220; show_bottom_space=&#8220;on&#8220;]<\/p>\n<p>&nbsp;<\/p>\n<p>[\/et_pb_image][et_pb_text _builder_version=&#8220;3.0.106&#8243; background_layout=&#8220;light&#8220;]<\/p>\n<h2>REST API<\/h2>\n<p>The <a href=\"https:\/\/docs.tibco.com\/pub\/js-jrs\/6.2.4\/doc\/pdf\/JasperReports-Server-REST-API-Reference.pdf\">Jasper Reports REST API<\/a> is a very powerful way to access Jasper Reports. It is very well documented and avaiable for both, Jasper Reports Pro and Community Edition. In my first tests, I used SoapUI to test the API and get a better understanding on how it works. As you can see in the video, I used XML rather than JSON for the data transfer.<\/p>\n<p>[\/et_pb_text][et_pb_video src=&#8220;https:\/\/pitss.org\/de\/wp-content\/uploads\/sites\/9\/2018\/04\/zoom_0.mp4&#8243; _builder_version=&#8220;3.0.106&#8243; \/][et_pb_text _builder_version=&#8220;3.0.106&#8243; background_layout=&#8220;light&#8220;]<\/p>\n<p>After I knew which API I needed, I asked myself, what would be a good language for the integration. I played a little bit with a Java Client but realized, that PL\/SQL already delivers a nice toolset for the integration of web services:<\/p>\n<ul>\n<li>APEX Web Service<\/li>\n<li>UTL_HTTP<\/li>\n<\/ul>\n<p>I chose UTL_HTTP for the first try and created a package for the integration:<\/p>\n<blockquote>\n<p style=\"text-align: left;\"><em> l_param_list := &#8218;&lt;?xml version=&#8220;1.0&#8243; encoding=&#8220;UTF-8&#8243; standalone=&#8220;yes&#8220;?&gt;&lt;reportExecutionRequest&gt;&lt;reportUnitUri&gt;&#8217;||REPORTUNITURI||'&lt;\/reportUnitUri&gt;&lt;async&gt;&#8217;||ASYNC||'&lt;\/async&gt;&lt;freshData&gt;&#8217;||FRESHDATA||'&lt;\/freshData&gt;&lt;saveDataSnapshot&gt;false&lt;\/saveDataSnapshot&gt;&lt;outputFormat&gt;&#8217;||OUTPUT_FORMAT||'&lt;\/outputFormat&gt;&lt;interactive&gt;&#8217;||INTERACTIVE||'&lt;\/interactive&gt;&lt;ignorePagination&gt;false&lt;\/ignorePagination&gt;&lt;parameters&gt;&lt;\/parameters&gt;&lt;\/reportExecutionRequest&gt;&#8216;;<\/em><\/p>\n<p style=\"text-align: left;\"><em>&#8212; preparing Request&#8230;<\/em><br \/>\n<em> l_http_request := UTL_HTTP.begin_request (&#8218;http:\/\/&#8217;||JASPER_SERVER||&#8216;:&#8217;||JASPER_PORT||&#8217;\/jasperserver-pro\/rest_v2\/reportExecutions&#8216;, &#8218;POST&#8216; , &#8218;HTTP\/1.1&#8216;);<\/em><\/p>\n<p><em>UTL_HTTP.write_text(l_http_request, l_param_list);<\/em><\/p><\/blockquote>\n<p>The idea is to establish the http-connection to the webservice (reportExecutionRequest), transfer the neccessary data, like report name and mode (synchronous vs. asynchronous). If successfully executed, the API will return a XML with an export-ID and a request-ID. I&#8217;ve used the XMLTYPE feature of the Oracle database to store the XML since it is not that big. If you have a 12c database there are also a lot of features to handle JSON responses.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-22480 size-full alignleft\" src=\"https:\/\/pitss.org\/de\/wp-content\/uploads\/sites\/9\/2018\/04\/xml.gif\" alt=\"xml\" width=\"445\" height=\"443\" \/>With for instance extractvalue the IDs can be extracted and you can actually grab the finished report. In my scenario I used the synchronous call. If you would like to call the Report asynchronous, you first have to get the status information before you try to get the result. Anyway if you call the report synchronously, the first request will wait for the report to be finished and you will just have to get the final document with:<\/p>\n<p><strong>\u00a0l_http_request := UTL_HTTP.begin_request( &#8218;http:\/\/&#8217;||JASPER_SERVER||&#8216;:&#8217;||JASPER_PORT||&#8217;\/jasperserver-pro\/rest_v2\/reportExecutions\/&#8217;||v_request_id||&#8217;\/exports\/&#8217;||v_export_id||&#8217;\/outputResource&#8216; , &#8218;GET&#8216; , &#8218;HTTP\/1.1&#8216;);<\/strong><\/p>\n<p>I used UTL_HTTP.READ_RAW to read the result from the response-handler and store the report as a BLOB in the database. You can see the whole process in the video below.<\/p>\n<p>[\/et_pb_text][et_pb_video src=&#8220;https:\/\/pitss.org\/de\/wp-content\/uploads\/sites\/9\/2018\/04\/zoom_6.mp4&#8243; _builder_version=&#8220;3.0.106&#8243; \/][\/et_pb_column_inner][\/et_pb_row_inner][\/et_pb_column][et_pb_column type=&#8220;1_4&#8243;][et_pb_search exclude_pages=&#8220;on&#8220; exclude_posts=&#8220;off&#8220; include_categories=&#8220;118,189,147,199,19,173,175,176,5,112,180,18,150,141,153,142,200,144,190,80,185,177,137,159,96,161,99,113,191,192,201,25,162,202,203,82,97,105,106,151,107,108,194,193,156,186,154,121,100,3,69,148,195,85,131,170,115,86,160,87,145,117,196,114,138,2,133,83,164,165,98,143,139,109,157,166,110,158,111,102,167,155,168,197,163,84,101,4,171,204,140,116,178,174,136,187,179,103,1,198,172,152,169,188,91,104,92,149&#8243; placeholder=&#8220;Artikel suchen&#8220; button_color=&#8220;#006bb3&#8243; _builder_version=&#8220;3.0.74&#8243; button_text_color=&#8220;#ffffff&#8220; module_alignment=&#8220;left&#8220; hide_button=&#8220;off&#8220;]<\/p>\n<p>&nbsp;<\/p>\n<p>[\/et_pb_search][et_pb_sidebar orientation=&#8220;right&#8220; area=&#8220;et_pb_widget_area_1&#8243; _builder_version=&#8220;3.0.74&#8243;]<\/p>\n<p>&nbsp;<\/p>\n<p>[\/et_pb_sidebar][et_pb_button button_url=&#8220;https:\/\/pitss.org\/de\/techblog&#8220; button_text=&#8220;\u2191 Zur\u00fcck zur \u00dcbersicht&#8220; button_alignment=&#8220;center&#8220; _builder_version=&#8220;3.0.74&#8243; custom_button=&#8220;on&#8220; button_text_size=&#8220;16&#8243; button_text_color=&#8220;#9b9b9b&#8220; button_border_color=&#8220;#d2d2d2&#8243; button_letter_spacing=&#8220;0&#8243;]<\/p>\n<p>&nbsp;<\/p>\n<p>[\/et_pb_button][\/et_pb_column][\/et_pb_section][et_pb_section bb_built=&#8220;1&#8243; _builder_version=&#8220;3.0.47&#8243; prev_background_color=&#8220;#000000&#8243;][et_pb_row _builder_version=&#8220;3.0.47&#8243; background_size=&#8220;initial&#8220; background_position=&#8220;top_left&#8220; background_repeat=&#8220;repeat&#8220;][et_pb_column type=&#8220;4_4&#8243;][et_pb_comments _builder_version=&#8220;3.0.106&#8243; show_avatar=&#8220;on&#8220; show_reply=&#8220;on&#8220; show_count=&#8220;off&#8220; background_layout=&#8220;light&#8220; header_font_size_tablet=&#8220;51&#8243; header_line_height_tablet=&#8220;2&#8243; custom_button=&#8220;off&#8220; button_icon_placement=&#8220;right&#8220;]<\/p>\n<p>&nbsp;<\/p>\n<p>[\/et_pb_comments][\/et_pb_column][\/et_pb_row][\/et_pb_section]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Jasper Reports &#8211; Javascript &#038; PL\/SQL Integration &nbsp; In the last couple of months there has been a lot of information on how to migrate Oracle Reports to other modern reporting tools. For me, as I am dealing mostly with Jasper Reports, the question came up on how we actually can integrate Jasper Reports in Oracle Forms or other tools. [&hellip;]<\/p>\n","protected":false},"author":47,"featured_media":22527,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"on","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[159,151,138,155,81],"tags":[271,268,207,251,127,270,269],"class_list":["post-19397","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-development","category-forms-modernization","category-modernization","category-oracle-reports","category-tech-blog","tag-api","tag-integration","tag-jasper-reports","tag-javascript","tag-oracle-forms","tag-rest","tag-webapplication"],"_links":{"self":[{"href":"https:\/\/pitss.org\/de\/wp-json\/wp\/v2\/posts\/19397","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pitss.org\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pitss.org\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pitss.org\/de\/wp-json\/wp\/v2\/users\/47"}],"replies":[{"embeddable":true,"href":"https:\/\/pitss.org\/de\/wp-json\/wp\/v2\/comments?post=19397"}],"version-history":[{"count":20,"href":"https:\/\/pitss.org\/de\/wp-json\/wp\/v2\/posts\/19397\/revisions"}],"predecessor-version":[{"id":22507,"href":"https:\/\/pitss.org\/de\/wp-json\/wp\/v2\/posts\/19397\/revisions\/22507"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pitss.org\/de\/wp-json\/wp\/v2\/media\/22527"}],"wp:attachment":[{"href":"https:\/\/pitss.org\/de\/wp-json\/wp\/v2\/media?parent=19397"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pitss.org\/de\/wp-json\/wp\/v2\/categories?post=19397"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pitss.org\/de\/wp-json\/wp\/v2\/tags?post=19397"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}