请求API的Magento Go C#初始化失败

本文关键字:初始化 失败 Go Magento API 请求 | 更新日期: 2023-09-27 18:22:39

我正在尝试使用C#连接到Magento API。我正在使用Magento Go服务,从我读到的内容来看,我可以使用他们的API-我希望我没有错。以下是我所做的:

我向http://mydomain.gostorego.com/api/v2_soap?wsdl=1添加了一个服务引用,仅添加一个服务就可以了。现在我用GetStuff()方法创建了一个test类,如下所示:

using ww.Feeds.MagnetoGoService;
public static string GetStuff()
{
     MagnetoGoService.Mage_Api_Model_Server_V2_HandlerPortTypeClient s = new MagnetoGoService.Mage_Api_Model_Server_V2_HandlerPortTypeClient();
     var login = s.login("username here", "key here");
     return login.ToString();
}

当我运行该程序时,我在第一行中得到一个错误:Could not find default endpoint element that references contract 'MagnetoGoService.Mage_Api_Model_Server_V2_HandlerPortType' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.

你知道这可能是什么吗?我必须在我的Magento Go设置中设置一些东西吗?或者可能使用Magento Go不允许访问API?

非常感谢。

请求API的Magento Go C#初始化失败

用c#忘记SOAP,你会把头发拔出来的。下载Charls-Cook的c#的xml-rpc-api库并使用xml-rpc方法。你不会得到所有时髦的智能,但至少它会起作用。还有ez.newsletter的c#解决方案,他们与库克的库一起发布,演示了如何使用80%的magento api调用。

库克图书馆xml-rpc.nethttp://www.xml-rpc.net/

ez.newsletter解决方案http://code.google.com/p/csharlibformagexmlrpcapi/

如果有人对此有问题,我的解决方案是:

我在一个项目中使用了引用,但实际上我调用了该类,并在另一个项目上使用了主程序。无论你在哪里使用服务,你都需要在每个项目中使用它。这就解决了问题!或者,您可以创建一个新的BasicHttpBinding(),并将app.config/web.config中的所有选项放入该绑定器中,这样就不需要到处引用Service。我希望这能有所帮助!