這幫助了很多感謝
回答11月16日在'11 7:26博提
你把它放到一個新的空白文件中。將其保存爲名稱。PHP UND運行,這是你的服務器上:
<?php
$host = "127.0.0.1/magento/index.php"; //our online shop url
$client = new SoapClient("http://".$host."/api/soap/?wsdl"); //soap handle
$apiuser= "user"; //webservice user login
$apikey = "key"; //webservice user pass
$action = "sales_order.list"; //an action to call later (loading Sales Order List)
try {
$sess_id= $client->login($apiuser, $apikey); //we do login
print_r($client->call($sess_id, $action));
}
catch (Exception $e) { //while an error has occured
echo "==> Error: ".$e->getMessage(); //we print this
exit();
}
?>
大家好,
解決的辦法是:
從Magento的管理面板...
System -> Configuration -> Web -> Url Options -> Add Store Code to Urls = NO
和!!!!
Auto-redirect to Base URL = NO
然後從
System -> Web Services-> Users
添加用戶使用戶與SoapClient的使用
然後使從
System -> Web Services -> Roles
一個角色,如果你想做到這一點附上所有資源這條路。
這很重要!從
;extension=php_soap.dll
到
extension=php_soap.dll
然後你可以用這個用戶我用這個代碼連接添加這個角色到你剛剛創建
還要確保php.ini中的用戶
$proxy = new SoapClient(’http://localhost/api/soap/?wsdl’,array(
$apiuser = "user",
$apikey = "key"));
從forgesource下載soapui http://sourceforge.net/projects/soapui/?source=directory
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:Magento">
<soapenv:Header/>
<soapenv:Body>
<urn:login soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<username xsi:type="xsd:string">username</username>
<apiKey xsi:type="xsd:string">password</apiKey>
</urn:login>
</soapenv:Body>
</soapenv:Envelope>
獲取我們的服務器的鏈接與下面的鏈接,並保存爲magentoV2.wsdl
http://localhost/index.php/api/v2_soap?wsdl
我希望這會幫助別人,因爲我丟失了半天,因爲有明白這個簡單的事情沒有足夠的詳細信息在一個地方。
HR
對延遲的遺憾感到遺憾,所以我只是在瀏覽器中打開這個文件?使用Php_soap ext啓動運行wamp server 2.1我需要任何東西來運行腳本?非常感謝 – Ledgemonkey
是的只能在瀏覽器中運行這個腳本。 ;)您需要在Magento後端添加Webservice用戶和角色。然後腳本應該可以工作:) – boti
您也可以從命令行運行這些PHP SOAP腳本,例如。 php name.php。這在測試時非常有用,因爲您不必使用HTML報告所有內容。 – Pete855217