Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从VB.NET调用Magento API_Vb.net_Api_Magento - Fatal编程技术网

如何从VB.NET调用Magento API

如何从VB.NET调用Magento API,vb.net,api,magento,Vb.net,Api,Magento,Magento有一个API,似乎有些人通过VB.NET使用它,但我在尝试了很多小时后无法让它工作 我在Magento 1.7.0.2上 正在尝试使VB.NET应用程序与API一起工作。 我正在使用符合WS-I的web服务设置 错误1自定义工具错误:无法导入Web服务/架构。无法从命名空间“urn:Magento”导入绑定“Mage\u Api\u Model\u Server\u Wsi\u HandlerBinding”。命名空间“urn:Magento”中portType“Mage\u Ap

Magento有一个API,似乎有些人通过VB.NET使用它,但我在尝试了很多小时后无法让它工作

我在Magento 1.7.0.2上 正在尝试使VB.NET应用程序与API一起工作。 我正在使用符合WS-I的web服务设置

错误1自定义工具错误:无法导入Web服务/架构。无法从命名空间“urn:Magento”导入绑定“Mage\u Api\u Model\u Server\u Wsi\u HandlerBinding”。命名空间“urn:Magento”中portType“Mage\u Api\u Model\u Server\u Wsi\u HandlerPortType”上的“catalogProductAttributeRemove”操作出现以下语法错误:该操作没有匹配的绑定。检查Binding部分中的操作、输入和输出名称是否与PortType部分中的相应名称匹配。d:\Documents\Visual Studio 2010\Projects\Mage\Mage\My Project\Settings.Settings 1 1 Mage

如果我尝试将其添加为服务引用(而不是Web引用),我会得到一组不同的错误

无法导入wsdl:绑定 无法导入wsdl:端口 无法导入wsdl:portType

错误5自定义工具错误:无法为服务引用“ServiceReference1”生成代码。有关详细信息,请查看其他错误和警告消息。d:\Documents\Visual Studio 2010\Projects\Mage\Mage\Service References\servicerence1\Reference.svcmap 1 1 Mage

警告3自定义工具警告:无法导入wsdl:绑定 详细信息:导入wsdl:binding依赖的wsdl:portType时出错。 XPath到wsdl:portType://wsdl:definitions[@targetNamespace='urn:Magento']/wsdl:portType[@name='Mage\u Api\u Model\u Server\u Wsi\u HandlerPortType'] XPath到错误源://wsdl:definitions[@targetNamespace='urn:Magento']/wsdl:binding[@name='Mage\u Api\u Model\u Server\u Wsi\u HandlerBinding']d:\Documents\Visual Studio 2010\Projects\Mage\Mage\Service References\servicerence1\Reference.svcmap 1 1 Mage

警告4自定义工具警告:无法导入wsdl:端口 详细信息:导入wsdl:端口所依赖的wsdl:绑定时出错。 XPath到wsdl:binding://wsdl:definitions[@targetNamespace='urn:Magento']/wsdl:binding[@name='Mage\u Api\u Model\u Server\u Wsi\u HandlerBinding'] XPath到错误源://wsdl:definitions[@targetNamespace='urn:Magento']/wsdl:service[@name='MagentoService']/wsdl:port[@name='Mage\u Api\u Model\u Server\u Wsi\u HandlerPort']d:\Documents\visualstudio 2010\Projects\Mage\Mage\service References\servicerence1\Reference.svcmap 1 Mage

警告2自定义工具警告:无法导入wsdl:portType 详细信息:运行WSDL导入扩展时引发异常:System.ServiceModel.Description.XmlSerializerMessageCompactImporter 错误:命名空间urn:Magento中名为catalogProductAttributeRemoveRequest的元素消息丢失。 XPath到错误源://wsdl:definitions[@targetNamespace='urn:Magento']/wsdl:portType[@name='Mage\u Api\u Model\u Server\u Wsi\u HandlerPortType']d:\Documents\Visual Studio 2010\Projects\Mage\Mage\Service References\servicerence1\Reference.svcmap 1 1 Mage


有人能给我非常明确的指令/代码,告诉我如何打电话并得到结果吗?我甚至无法正确地获得初始配置。我下载了其他人在线提供的一些代码,但如果不起作用,可能是因为它是针对早期版本的。

您可能想尝试一下这个示例

此外,还可以在此处找到更详细的Magento C#库:

这段代码显然需要调整——我没有时间来美化这些东西


来自阿比德·侯赛因的链接

1。使用wdsl工具,我通过调用创建了一个.vb源文件:

Private WithEvents msvc As New MagentoService() 
wsdl/language:VB/out:MageProxyClass.VBhttp:///api/v2_soap?wsdl

2。之后,我使用VB组件和行编辑器将源文件编译成dll。

Private WithEvents msvc As New MagentoService() 
vbc/out:MageProxyClass.dll/t:library /r:System.XML.dll,System.Web.Services.dll MageProxyClass.vb

3。最后,我能够创建在我的MageProxyClass.dll中定义的MagentoService类的实例

Private WithEvents msvc As New MagentoService() 
4。示例:

 Public Class main
    Private WithEvents msvc As New MagentoService()
    Private ssid As String
    Private Sub main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ListBox1.Items.Clear()
        ListBox1.Items.Add("Trying to connect")
        msvc.loginAsync("xxxx", "xxxxxxxxxxxxxxxx")
    End Sub

    Public Sub MageLoginComplete(ByVal sender As System.Object, ByVal e As loginCompletedEventArgs) Handles msvc.loginCompleted
        ListBox1.Items.Add("Login completed")
        ssid = e.Result
        ListBox1.Items.Add(String.Concat("Session ID: ", ssid))
    End Sub
End Class 

终于让它工作了

像往常一样添加您的Web服务(它将无法编译,但仍将添加它)

打开Magento.wsdl(或您的VS在web引用中调用的wsdl文件),并完全删除对catalogProductAttributeRemove的调用

 <!--wsdl:operation name="catalogProductAttributeRemove">
    <wsdl:documentation>Delete attribute</wsdl:documentation>
    <wsdl:input message="typens:catalogProductAttributeRemoveRequest" />
    <wsdl:output message="typens:catalogProductAttributeRemoveResponse" />
</wsdl:operation-->

启动Visual Studio命令提示符并导航到项目,然后单击“Web引用”

类型: wsdl/language:VB/out:Reference.VB Magento.wsdl/namespace:com.yourwebservicename.www


这将正确生成您需要继续的reference.vb文件。

您能在浏览器中查看web服务吗?是的,我在这里有一个测试站点:我认为API XML可能有问题,或者与.NET稍有不兼容,然而,似乎其他人已经成功地让它工作了。我在发布之前遵循了这些说明,但它们不起作用。不需要将代码编译成DLL,只需在VB.NET项目中访问它即可。你真的让它工作了吗?我将创建一个新的赏金,因为尽管stackoverflow自动授予您积分,但我的问题仍然没有解决方案。