这里仅以Delphi为例,其它开发语言类似!
最近需要将Magento(国外比较出名的开源PHP+MySQL电子商务网站)与一个ERP进行整合,就需要调用Magento的Webservice。
Magento提供3套api。
(
SOAP adapter is default adapter for webservices. If you want to connect to Magento SOAP webservices you should load WSDL from this link (http://youmagentohost/api/?wsdl or http://youmagentohost/api/soap/?wsdl ) in your SoapClient
As of v1.3 you may also use http://yourmagentohost/api/v2_soap?wsdl=1 which has been added to improve compatbility with Java and .NET.
)
注:如果需要同构调用需要使用1、2个wsdl,如调用方为.NET、Java、Delphi等请使用v2_soap。
调用步骤
一、在Magento中创建调用Webservice的用户名与密码(进入Magento后台管理->System->Web Services->Users),在创建用户前先设计一个角色(进入Magento后台管理->System->Web Services->Roles),用来对调用Webservice的权限进行限制
二、在Delphi端用WSDL Import工具进行导入,导入后会自动生成相关对象的类信息
三、使用Magento的接口,调用login、salesOrderInfo等函数
(注:在使用catalogProductCreate时经常会出现the operation is time out现象,在D7中经常出现,建议将创建产品的过程写在线程中)
例1:搜索相关状态的订单
例2:Load订单明细