General
In the previous post we have improved the solution allowing running SQL queries from VB AppUIs by utilizing BIP lexicals.
The solution was based on the following:
- BIP report receiving an SQL query and returning JSON response, utilizing the lexicals feature.
- OIC integration that invokes the report above and returns its JSON response, utilizing a binary output feature of OIC to return JSON built by the query.
- Custom Object row level externally exposed Groovy method, available in VB AppUI projects, calling the integration above and returning results as a JSON array, easily invocable from Javascript action chains.
The last solution element relies on REST Web Service definition that points to an OIC instance. Such a connection should be updated after P2T process to ensure that no TEST instance will access PROD.
The new proposed solution utilizes the fa-internal.oracleoutsourcing.com hostname to call the BIP report above and return the generic response by groovy code only. No OIC involved.
Such a solution is completely hassle-free in P2T process as the logical name above is pointing to the current environment.
The solution below will explain how to setup the connection above, implement the groovy method and finally call it from Javascript chains in VBCS AppUIs.
High Level Implementation Details
- Define a connection named LocalWssReport pointing to https://fa-internal.oracleoutsourcing.com:10663/xmlpserver/services/ExternalReportWSSService?wsdl
- Use “Propagate user identity using SAML” to allow seamless login
- Implement Application Composer groovy function to call the report returning XML with JSON inside
- Extract the JSON output, unescape the XML special chars and return
- Use JSON.parse inside action chain to convert the response to easily usable format
Detailed Implementation Details
- Define a generic report execution SOAP connection to https://fa-internal.oracleoutsourcing.com:10663/xmlpserver/services/ExternalReportWSSService?wsdl in App Composer:
- Implement groovy row level function (object level can not access web services), assuming the report is uploaded to the location /Custom/Integrations/Utils/RunSQLToJson.xdo:
def reportRequest = [ byPassCache :true, reportAbsolutePath :'/Custom/Integrations/Utils/RunSQLToJson.xdo', sizeOfDataChunkDownload :-1, attributeFormat: 'xml', parameterNameValues: [ item: [[ name :'p_sql', values: [ item: [[ item :sqlText, ]], ], ]], ], ]; def appParams = ''; def report = adf.webServices.LocalWssReport.runReport(reportRequest, appParams); def repResult = decodeBase64(report.reportBytes.toString()); def json = ''; if (contains(repResult, '</JSON_DOC>')) { json = substringAfter(repResult, '<JSON_DOC>'); json = substringBefore(json,'</JSON_DOC>'); } if (json == '') return '[]' return json.replaceAll("&", "&") .replaceAll("<", "<") .replaceAll(">", ">") .replaceAll(""", "\"") .replaceAll("'", "'")
- Test the method above in Postman:
- Use JSON.parse in action chain to use the output above.