Quantcast
Viewing all articles
Browse latest Browse all 82002

Cross domain Javascript using XMLHttpRequest in CRM 2011 rollup11-13 on IE10

One of our customers has asked for automatic validation of bank account numbers, including conversion from the old Belgian BBAN system to IBAN and lookup of the BIC number. To facilitate this, we want to call a webservice from Javascript. The webservice is located at http://www.ibanbic.be/IBANBIC.asmx. an alternative mirror is located at http://www.ebcs.be/iban/IBANBIC.asmx This webservice should be called in the following manner:

POST /IBANBIC.asmx HTTP/1.1
Host: www.ibanbic.be //www.ebcs.be
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/controleIBAN"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <controleIBAN xmlns="http://tempuri.org/">
      <iban>string</iban>
    </controleIBAN>
  </soap:Body>
</soap:Envelope>

I have managed to get this fully operational using an ActiveXObject with rollup 11. However, in order to prepare for our imminent move to rollup 13, I should use XMLHttpRequest. 

our ActiveXObject code is as such:

var xml = createXml(functionname, xmltagtype, banknummer);
var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
xmlhttp.open("POST", "http://www.ibanbic.be/IBANBIC.asmx", false);
xmlhttp.setRequestHeader("SOAPAction", "http://tempuri.org/" + functionname);
xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlhttp.setRequestHeader("Content-Length", xml.length);
xmlhttp.setRequestHeader("Host", "www.ibanbic.be");
xmlhttp.send(xml);
return xmlhttp.responseXML.text;

This fully works and returns no errors. I now tried to adapt this code for XMLHttpRequest:

var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST", "http://www.ibanbic.be/IBANBIC.asmx", false);
xmlhttp.setRequestHeader("SOAPAction", "http://tempuri.org/" + functionname);
xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlhttp.setRequestHeader("Content-Length", xml.length);
xmlhttp.setRequestHeader("Host", "www.ibanbic.be");
xmlhttp.send(xml);
return xmlhttp.responseXML.lastChild.textContent;

However, this throws an error at the xmlhttp.open command, citing "access is denied". I've searched this error code and it appears to be because IE10 does not allow cross domain calls. I have, however, enabled both mixed content, access across domains and other options which people recommend for both our CRM domain and the target webservice domain.

What would be the best way to resolve this? I'm willing to use JQuery if it's needed.

I've attached a zip file which contains the aspx page which I use for trial reasons. this one should work.

I'm thinking it could also have something to do with some sort of throttling on the webservice, but not sure.


Viewing all articles
Browse latest Browse all 82002

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>