Mar*_*tin 0 c# api web-services magento
我试图连接到Magento 1.4.0.1 API,但直到现在我没有运气.
我添加了一个Service Reference命名MagentoAPI并指向它http://mydomain.com/api/v2_soap?wsdl=1(我知道=1它不是有意的,但它没有用)
这工作正常,我得到了所有可用方法的列表,但是当我尝试使用它们中的任何一个时它都不起作用.
using Magento_Import.MagentoAPI;
namespace Magento_Import
{
public partial class _Default : System.Web.UI.Page
{
Mage_Api_Model_Server_V2_HandlerPortType handler;
protected void Page_Load(object sender, EventArgs e)
{
string session = handler.login("username", "password");
}
}
}
Run Code Online (Sandbox Code Playgroud)
这就是我如何初始化网络服务,但是当我调试的代码handler是null.
我究竟做错了什么?
好的,我通过这样做得到了它:
using Magento_Import.MagentoAPI;
namespace Magento_Import
{
public partial class _Default : System.Web.UI.Page
{
Mage_Api_Model_Server_V2_HandlerPortTypeClient handler = new Mage_Api_Model_Server_V2_HandlerPortTypeClient();
protected void Page_Load(object sender, EventArgs e)
{
string session = handler.login("username", "password");
catalogProductEntity[] products;
handler.catalogProductList(out products, session, null, null);
}
}
}
Run Code Online (Sandbox Code Playgroud)
但我不确定这是最好的做法,如果有人知道更好的方法,请这样说:D