是否可以使用jquery获取跨域SOAP请求

时间:2012-08-23 10:56:50

标签: jquery

我正在使用javascript来获取肥皂回复 但经过很多痛苦,我意识到不可能获得跨域xml http请求。 所以我决定转向jquery 现在我不需要代码 我只需要一些提示和确认,如果可能的话在jquery中 下面是我的js的代码  var getmarket = new XMLHttpRequest();         getmarket.open('POST','http://www.betfair.com/publicapi/',true);

    var m_request = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" '+
                    'xmlns:bfex="http://www.betfair.com/publicapi/v5/BFExchangeService/" '+
                    'xmlns:v5="http://www.betfair.com/publicapi/types/exchange/v5/">'+
                    ' <soapenv:Header/>'+
                    '<soapenv:Body>'+
                    '<bfex:getAllMarkets>'+
                    '<bfex:request>'+
                    '<header>'+
                       '<clientStamp>0</clientStamp>'+
                       '<sessionToken>Y9eTuEvlrTM55pbRB1kIj0As0bVvz3eFm+p1FY+svHk=</sessionToken>'+
                    '</header>'+
                    '<locale>en</locale>'+
                    '<eventTypeIds>'+
                       '<v5:int>1</v5:int>'+
                    '</eventTypeIds>'+
                    '<countries>'+
                       '<v5:Country>GBR</v5:Country>'+
                    '</countries>'+
                    '<fromDate>2012-08-23TO00:00:00.000Z</fromDate>'+
                    '<toDate>2012-08-24TO00:00:00.000Z</toDate>'+
                 '</bfex:request>'+
              '</bfex:getAllMarkets>'+
           '</soapenv:Body>'+
        '</soapenv:Envelope>';

    getmarket.onreadystatechange = function (){
        if (getmarket.readyState == 4 && getmarket.status == 200)
        document.write(getmarket.responseText);
        }

    getmarket.setRequestHeader('Content-Type', 'text/xml');
    getmarket.send(m_request);
    document.write(getmarket.responseText);

2 个答案:

答案 0 :(得分:2)

您无法执行此操作,只允许JSONP跨域。

另请查看:Cross-domain SOAP from the browser

答案 1 :(得分:2)

JQuery是Javascript的包装器。如果javascript不会这样做,JQuery也不会。您必须让服务器进行查找。