Monday, October 24, 2011

ISG, JavaScript and Mobile Web Browsers

After getting ISG to work with SSL enabled for eBusiness Suite R12, the challenge was to get the JavaScript to work with all desktop and mobile browsers. It took me a while to figure this out and I had to ping some of my web development guru friends for help, but it works now!
If you look at the stub JS script for FND_PROFILE, you will find the function FND_PROFILE_Port_GET(_NAME) which basically creates the SOAP envelope and body and the calls the web service using XMLHttpRequest or ActiveXObject("Microsoft.XMLHTTP") for Internet Explorer. The script uses XMLDOM ( document.implementation.createDocument or ActiveXObject("Microsoft.XMLDOM")) to create a new XML document. To create elements and attributes, it uses createElement, createElementNS. 
Well, createElementNS works differently on Firefox than it does on IE, Chrome or Safari in that it uses the namespace to create an element with the namespace attribute.  For example the output from
var envelope = createElementNS(xmlDoc, 'http://schemas.xmlsoap.org/soap/envelope/', 'soapenv:Envelope'); 
in Firefox is <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">. In the other desktop browsers the output is <soapenv:Envelope>.
Modifying all createElementNS calls to createElement, I got this working on all desktop and almost all mobile browsers - BlackBerry just refused to comply. I must have gone through over a 100 BlackBerry and JavaScript links that resulted from a Google search but I'd always end up with the same result - no luck on BlackBerry browsers. 
I then changed my approach - instead of using createDocument and createElement, I created the XML as a string and loaded the string into an XML document. Not a very elegant solution, but it gets the job done. 

if (window.DOMParser)
{
parser=new DOMParser();
xmlDoc=parser.parseFromString(xmlString,"text/xml");
}
else // Internet Explorer
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.loadXML(xmlString); 

DOMParser is only available on BlackBerry versions 4.7.1 and up.




No comments:

Post a Comment