Invoking SOAP Services from Oracle Visual Builder [Part 2]


In Part 1, we set up a SOAP service connection in VBCS, built a SOAP request, and successfully invoked a BI Publisher report using the ExternalReportWSSService. The API responded with a base64-encoded payload — in our case, a CSV containing the report data.
Now it’s time to turn that raw payload into something your application can use. In this post, we’ll decode the base64 output, parse it into JSON using the Papa Parse library, and store it in a VBCS variable so it can be displayed in the UI. We’ll also look at the slight adjustments needed when using this in an AppUI extension.
Parsing the SOAP Response
The sample BIP which i had created had the output set to CSV. Hence the JS callBIP
would return the base64 encoded csv output. We would need to parse the CSV into a JSON and store in an Variable to show in the UI.
Key Points
We are using a library to convert CSV to JSON. Refer this article to learn more. https://satishkumar.hashnode.dev/how-to-parse-csv-data-in-oracle-visual-builder-using-js-library
If you get an XML and want to parse that, refer : https://satishkumar.hashnode.dev/how-to-parse-xml-data-in-oracle-visual-builder-using-js-library
This function accepts the report output from the previous call and returns an array of object.
parseCSV(reportOutput) {
let Output = decodeURIComponent(window.escape(atob(reportOutput)));
let response = Papa.parse(Output.trim(), { header: true });
console.log(response.data);
return response.data;
}
Final JS File
define(['vb/helpers/rest', 'papa'], (Rest, Papa) => {
'use strict';
class PageModule {
callBIP() {
return new Promise(function (resolve, reject) {
let soapRequest = '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:pub="http://xmlns.oracle.com/oxp/service/PublicReportService">\
<soap:Header/>\
<soap:Body>\
<pub:runReport>\
<pub:reportRequest>\
<pub:parameterNameValues>\
</pub:parameterNameValues>\
<pub:reportAbsolutePath>/Custom/SOAPDemo/DemoRPT.xdo</pub:reportAbsolutePath>\
<pub:sizeOfDataChunkDownload>-1</pub:sizeOfDataChunkDownload>\
</pub:reportRequest>\
</pub:runReport>\
</soap:Body>\
</soap:Envelope>';
console.log(soapRequest);
Rest.get('ExternalReportWSSService/postXmlpserverServicesExternalReportWSSService').body(soapRequest).fetch().then(
response => {
let xmlResponse = $.parseXML(response.body);
let reportBytes = xmlResponse.getElementsByTagNameNS("*", "reportBytes")[0].textContent;
resolve(reportBytes);
});
});
}
parseCSV(reportOutput) {
let Output = decodeURIComponent(window.escape(atob(reportOutput)));
let response = Papa.parse(Output.trim(), { header: true });
console.log(response.data);
return response.data;
}
}
return PageModule;
});
Sample Application
Sample application can be found in my GIT Repo.
Bonus : Adapt this for APPUI Extensions
The above steps almost would remain the same for AppUI Extensions as well. But with a small minor difference. Check out the thread https://community.oracle.com/customerconnect/discussion/654918/vb-helpers-rest-does-not-work-in-appui
The parameters for VB Helper REST Utility would change for an APPUI Extension. You would need to pass
Rest.get('serviceId/endpointId', { extensionId: myExtensionId} )
Disclaimer : Invoke SOAP directly only when necessary. Its always best to keep the Client Side logic as less as possible and put the business logic on a Middleware like OIC.
Subscribe to my newsletter
Read articles from Satish Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Satish Kumar
Satish Kumar
The views, thoughts, and opinions expressed belong solely to the author, and not necessarily to the author's employer, organization, committee or other group or individual.