简体   繁体   中英

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

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..??

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).

如果您可以访问具有该服务的服务器,则可以按照以下网站上的说明轻松在服务器上启用cors: http ://enable-cors.org/,其中提供了每种类型的Web服务器的示例。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM