这帮助很大,谢谢
回答于 2011 年 11 月 16 日 7:26 boti
你把它放到一个新的空白文件中。将此保存为 name.php 并在您的服务器上运行:
<?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
如果您想这样做,请附加所有资源。
这很重要!将此角色添加到您刚刚创建的用户中
还要确保 PHP.ini 来自
;extension=php_soap.dll
到
extension=php_soap.dll
然后你可以和这个用户联系我使用这个代码
$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
我希望这对其他人有所帮助,因为我失去了半天的时间来理解这个简单的事情,因为一个地方没有足够的详细信息。
人力资源