2013-11-14 36 views
2

我目前正試圖訪問我的magento商店的SOAP API沒有成功。我在後端創建了一個soap用戶和角色,並通過xmlrpc登錄進行了測試。 同源策略不是問題。我通過URL myshop.com/api/?wsdl通過JavaScript訪問Magento SOAP API:我做錯了什麼?

我曾嘗試jquery soap client獲得WSDL:

$.soap({ 
    url: 'http://my-shop.de/api/', 
    method: 'login', 
    data: { 
     username:'soap_username', 
     apiKey:'soap_userpass' 
    }, 

    success: function (soapResponse) { 
     alert("yes!!"); 
    }, 
    error: function (SOAPResponse) { 
     alert(SOAPResponse.toString()); 

    } 

}) 

返回404,我無法找出原因。

除了我曾嘗試javascript soap client

var url = 'http://myshop.de/api/'; 
var pl = new SOAPClientParameters(); 
pl.add("username", 'soap_username'); 
pl.add("apiKey", 'soap_userpass'); 

SOAPClient.invoke(url, "login", pl, true, HelloTo_callBack); 

function HelloTo_callBack(r) { 
    alert(r.toString()); 
}; 

返回一個500內部服務器錯誤。再次,我不知道這裏出了什麼問題。 任何人都可以給我一個關於我失蹤的提示嗎?

任何幫助或提示表示讚賞,謝謝!

回答

-3

好的發現了問題! 這是維修模式。即使我的IP被列入白名單,我可以正常瀏覽商店和後端,不知何故,soap API調用會搞砸。所以對我工作的代碼是:

$.soap({ 
    url: 'http://my-shop.de/api/?wsdl', 
    method: 'login', 
    data: { 
     username:'soap_username', 
     apiKey:'soap_userpass' 
    }, 

    success: function (soapResponse) { 
     alert("yes!!"); 
    }, 
    error: function (SOAPResponse) { 
     alert(SOAPResponse.toString()); 

    } 

}) 

(注改變URL)

+0

我得到這個錯誤,嘗試你的代碼時: OPTIONS http://192.168.1.61/magento/index.php/api /?wsdllogin jQuery.ajaxTransport.send @ jquery-2.1.4.js:8630jQuery.extend.ajax @ jquery-2.1.4.js:8166SOAPEnvelope.send @ jquery.soap.js:226 $ .soap @ jquery.soap。 js:96(匿名函數)@ jquery.html:12 jquery.html:1 XMLHttpRequest無法加載http://192.168.1.61/magento/index.php/api/?wsdllogin。無效的HTTP狀態代碼500 jquery.soap.js:388未捕獲的錯誤:意外的內容:undefined –

+0

我也得到了與@AkramElHamdaoui相同的錯誤 –