加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

如何从VB.NET调用Magento API

发布时间:2020-12-17 00:32:51 所属栏目:大数据 来源:网络整理
导读:Magento有一个API,似乎有些人通过VB.NET使用它,但我尝试了很长时间后无法让它工作. 我在Magento 1.7.0.2上 试图让VB.NET应用程序使用API??. 我正在使用符合WS-I的Web服务设置. Error 1 Custom tool error: Unable to import WebService/Schema. Unable to im
Magento有一个API,似乎有些人通过VB.NET使用它,但我尝试了很长时间后无法让它工作.

我在Magento 1.7.0.2上
试图让VB.NET应用程序使用API??.
我正在使用符合WS-I的Web服务设置.

Error 1 Custom tool error: Unable to import WebService/Schema. Unable to import binding ‘Mage_Api_Model_Server_Wsi_HandlerBinding’ from namespace ‘urn:Magento’. The operation ‘catalogProductAttributeRemove’ on portType ‘Mage_Api_Model_Server_Wsi_HandlerPortType’ from namespace ‘urn:Magento’ had the following syntax error: The operation has no matching binding. Check if the operation,input and output names in the Binding section match with the corresponding names in the PortType section. d:DocumentsVisual Studio 2010ProjectsMageMageMy ProjectSettings.settings 1 1 Mage

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

无法导入wsdl:binding
无法导入wsdl:port
无法导入wsdl:portType

Error 5 Custom tool error: Failed to generate code for the service reference ‘ServiceReference1’. Please check other error and warning messages for details. d:DocumentsVisual Studio 2010ProjectsMageMageService ReferencesServiceReference1Reference.svcmap 1 1 Mage

Warning 3 Custom tool warning: Cannot import wsdl:binding
Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on.
XPath to wsdl:portType: //wsdl:definitions[@targetNamespace=’urn:Magento’]/wsdl:portType[@name=’Mage_Api_Model_Server_Wsi_HandlerPortType’]
XPath to Error Source: //wsdl:definitions[@targetNamespace=’urn:Magento’]/wsdl:binding[@name=’Mage_Api_Model_Server_Wsi_HandlerBinding’] d:DocumentsVisual Studio 2010ProjectsMageMageService ReferencesServiceReference1Reference.svcmap 1 1 Mage

Warning 4 Custom tool warning: Cannot import wsdl:port
Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on.
XPath to wsdl:binding: //wsdl:definitions[@targetNamespace=’urn:Magento’]/wsdl:binding[@name=’Mage_Api_Model_Server_Wsi_HandlerBinding’]
XPath to Error Source: //wsdl:definitions[@targetNamespace=’urn:Magento’]/wsdl:service[@name=’MagentoService’]/wsdl:port[@name=’Mage_Api_Model_Server_Wsi_HandlerPort’] d:DocumentsVisual Studio 2010ProjectsMageMageService ReferencesServiceReference1Reference.svcmap 1 1 Mage

Warning 2 Custom tool warning: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.XmlSerializerMessageContractImporter
Error: Element message named catalogProductAttributeRemoveRequest from namespace urn:Magento is missing.
XPath to Error Source: //wsdl:definitions[@targetNamespace=’urn:Magento’]/wsdl:portType[@name=’Mage_Api_Model_Server_Wsi_HandlerPortType’] d:DocumentsVisual Studio 2010ProjectsMageMageService ReferencesServiceReference1Reference.svcmap 1 1 Mage

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

Function getHTTPStream() As String
    Dim myh As HttpWebRequest = _
    HttpWebRequest.Create("http://yourmagentoweb/soap/api/?wsdl")
    myh.Timeout = 30000
    myh.UserAgent = "Test"
    Dim myR As HttpWebResponse = myh.GetResponse()
    Dim myEnc As Encoding = Encoding.GetEncoding(1252)
    Dim mySr As StreamReader = New StreamReader(myR.GetResponseStream(),myEnc)

    Return mySr.ReadToEnd()
End Function

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

来自Abid Hussain的链接

1.使用wdsl工具我通过调用以下方法创建了一个.vb源文件:

wsdl /language:VB /out:MageProxyClass.vb http:///api/v2_soap?wsdl

2.之后我使用VB Comand Line Editor将源文件编译成dll.

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读