Click here to Skip to main content
15,885,941 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All I am trying to access the web service using java script but it gives flowing error :
NETWORK_ERR: XMLHttpRequest Exception 101

Please help me out to fix the issue

XML
<script type="text/jscript" language="javascript">
    var xmlHttp;
    function SoapCall() {
        // creatng the xmlHttp object
        var xmlHttp;
        if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlHttp = new XMLHttpRequest();
        }
        else {// code for IE6, IE5
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        // Calling the web service using post and true means asynchronous call
        xmlHttp.open("post", "http://www.webservicex.net/CurrencyConvertor.asmx", false);
        // Setting the request header to let the web service identify the soap request we would be sending

        xmlHttp.setRequestHeader("Content-Type", "text/xml;charset=utf-8");

        xmlHttp.setRequestHeader("SOAPAction", "http://www.webserviceX.NET/ConversionRate");

        var soapRequest = '<?xml version="1.0" encoding="utf-16"?>' +
'<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">' +
  '<soap:Body>' +
    '<ConversionRate xmlns="http://www.webserviceX.NET/">' +
      '<FromCurrency>AFA</FromCurrency>' +
      '<ToCurrency>AFA</ToCurrency>' +
    '</ConversionRate>' +
  '</soap:Body>' +
'</soap:Envelope>';

        xmlHttp.send(soapRequest);
        alert(xmlHttp.responseText);
    }
    </script>
Posted

1 solution

Sounds like a cross domain scripting problem...

http://stackoverflow.com/questions/2235929/network-error-xmlhttprequest-exception-101[^]

In these situations, I would normally proxy the call to the 3rd party service through a service on my own domain. So, your javascript calls *your* service (which you need to write) which simply forwards the call onto the 3rd party.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900