0

Javascript を使用して SOAP リクエストを作成しようとしていますが、機能していないようです。使用されている以下のコードを見つけてください。

URL="http://footballpool.dataaccess.eu/data/info.wso";
xmlStr="<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><AllDefenders xmlns="http://footballpool.dataaccess.eu">   <sCountryName>string</sCountryName></AllDefenders></soap:Body></soap:Envelope>";

jQuery.ajax({
         type: "POST",
         url: URL,
         dataType: "xml",
         processData: false,
         data: xmlStr,
         beforeSend: function(req) {
            req.setRequestHeader("Method", "POST");
            req.setRequestHeader("Content-Type", "text/xml" + "; charset=\"" + "UTF-8" + "\"");
         }
    });

応答:

Object
OPTIONS http://footballpool.dataaccess.eu/data/info.wso 400 (Bad Request)
jquery.js:4 XMLHttpRequest cannot load http://footballpool.dataaccess.eu/data/info.wso. Origin http://www.know7.com is not allowed by Access-Control-Allow-Origin.

http://footballpool.dataaccess.eu/data/info.wso?op=AllDefendersからの応答を取得しようとしています

ありがとうございました..

4

3 に答える 3

1

You can't just call a url from other domain like that, or we would be all in really bad hands! You always need a proxy for what you're doing, either PHP, .NET, etc, that you would call that endpoint and receive the call and bypass to your javascript call.

You get the Cross Domain error:

Origin http://www.know7.com is not allowed by Access-Control-Allow-Origin.

That will tell you everything...

If you own this domain, you can open it up, by creating a cross-domain.xml file, as well add a Html header allowing the cross domain call.


They offer you a way to get JSON back, but they are not sending it wrapped in a function, so you will always get an error:

http://jsbin.com/ivobun/1/edit

So, except for a Proxy, there is nothing you can do.

于 2012-08-24T10:24:08.990 に答える
1

In addition to Endy's answer you might want to check out this article on Mozilla DevNet about cross domain access of resources, and related check the HTTP headers of the server response. Specifically what the content of the Access-Control-Allow-Origin header is as that will tell you which domains the server admins are allowing access to the specified resource.

https://developer.mozilla.org/en-US/docs/HTTP_access_control

于 2012-08-24T10:24:53.590 に答える
0

クロスドメインでリクエストを実行しようとしているようです。これは許可されていません。許可されているのは JSONP だけです。

于 2012-08-24T10:17:44.500 に答える