0

XMLHttpRequest cannot load http://ideone.com/api/1/service.wsdl. Origin null is not allowed by Access-Control-Allow-Origin.

please help me in this regard

 <html>
<head>
 <title> Web services </title>

<script type="text/javascript" src="jquery.js">
</script>

<script type="text/javascript" src="soapproxy.js">
</script>


<script type="text/javascript">


testob={user:"harisrinivas",pass:"ideonehari"};

function resultcallback(res, xml, text, proxy) {
            alert(res);
        }
        function failurecallback(res, xml, text, proxy) {
            alert("SayHello() failed");
        }
        function gotproxycallback(proxy, wsdl, text) {
            if (proxy instanceof SOAPProxy) {
               //proxy.SayHello(null, true, resultcallback, failurecallback);
               SOAPProxy.prototype.invoke(test, testob, async, resultcallback, faultcallback);

            } else {
                alert("Proxy not created!");
            }
        }
        $(document).ready(function () {
            try {
                SOAPProxyFabric.fromUrl("http://ideone.com/api/1/service.wsdl", true, gotproxycallback);
            } catch (x) {
                alert("Failed to load or parse WSDL!");
            }
        });
</script>

</head>


<body>

<h1> Web service testing by Hari Srinivas </h1>



</body>

</html>

i'm using jquery and soapproxy (http://code.google.com/p/js-soap-proxy/). What is the problem ? and how can i remove this error..??

  • Duplicate of http://stackoverflow.com/questions/3595515/xmlhttprequest-error-origin-null-is-not-allowed-by-access-control-allow-origin?rq=1 – Benjamin Gruenbaum Apr 04 '13 at 15:04

2 Answers2

0

I guess soapproxy fromurl uses xmlhttprequest, a page from website A is not allowed to make a request to website B. where:

A = google.com 
B = yahoo.com 
or 
A = mysite:80.com 
B = mysite:90.com 
or 
A = subdomain.mysite.com 
B = othersub.mysite.com

You can find same origin policy information on wikipedia. A way to go around it is JSONP but I don't think soapproxy uses it. Another way to quickly find out if this is your problem is get the forcecors plugin for firefox, activate it (view -> toolbars -> add on bar) click on cors (right bottom of the screen). If it's red you can connect from any site to any site because the plugin fiddles with the http response making it pretend that server B has send you the cors header (allowing other websites to connect to it with xmlhttprequests).

HMR
  • 37,593
  • 24
  • 91
  • 160
0

If you have access to the server that has the service on it, you can enable cors easily on the server by following directions on this site: http://enable-cors.org/ , they have examples for each type of webserver.

vbpal
  • 1
  • 1