How to call Magento API from VB.NET

Magento has an API, and it seems that some people use it through VB.NET, but I cannot get it to work after several hours.

Im on Magento 1.7.0.2 Trying to get a VB.NET application that works with the API. Im using a web service setup compatible with WS-I.

Error 1 Custom Tool Error: Cannot import WebService / Schema. Failed to import Mage_Api_Model_Server_Wsi_HandlerBinding from namespace urn: Magento. The operation 'catalogProductAttributeRemove on portType' Mage_Api_Model_Server_Wsi_HandlerPortType from the namespace 'urn: Magento had the following syntax error: the operation has no binding. Verify that the names of the operations, input and output in the Bind section match the names in the PortType section. d: \ Documents \ Visual Studio 2010 \ Projects \ Mage \ Mage \ My Project \ Settings.settings 1 1 Mag

if I try to add it as a service link (instead of a web link), I get a different set of errors.

Unable to import wsdl: binding Unable to import wsdl: port Unable to import wsdl: portType

Error 5 Custom tool error: Failed to create code for service reference "ServiceReference1". See other error and warning messages for more information. d: \ Documents \ Visual Studio 2010 \ Projects \ Mage \ Mage \ Service Links \ ServiceReference1 \ Reference.svcmap 1 1 Mag

3 : wsdl: binding : wsdl: portType, wsdl: binding. XPath to wsdl: portType://wsdl: [@targetNamespace = urn: Magento]/wsdl: portType [@ name= Mage_Api_Model_Server_Wsi_HandlerPortType] XPath to Error ://wsdl: [@targetNamespace = urn: Magento]/wsdl: binding [@name= Mage_Api_Model_Server_Wsi_HandlerBinding] d:\Documents\Visual Studio 2010\Projects\Mage\Mage\-\ServiceReference1\Reference.svcmap 1 1

4 : wsdl: : wsdl: binding, wsdl: . XPath to wsdl: binding://wsdl: [@targetNamespace = urn: Magento]/wsdl: binding [@ name= Mage_Api_Model_Server_Wsi_HandlerBinding] XPath to Error ://wsdl: [@targetNamespace = urn: Magento]/wsdl: service [@name= MagentoService]/wsdl: [@name= Mage_Api_Model_Server_Wsi_HandlerPort] d:\Documents\Visual Studio 2010\Projects\Mage\Mage\-\ServiceReference1\Reference.svcmap 1 1

2 : wsdl: portType : WSDL : System.ServiceModel.Description.XmlSerializerMessageContractImporter : catalogProductAttributeRemoveRequest urn: Magento . XPath to Error ://wsdl: [@targetNamespace = urn: Magento]/wsdl: portType [@ name= Mage_Api_Model_Server_Wsi_HandlerPortType] d:\Documents\Visual Studio 2010\Projects\Mage\Mage\-\ServiceReference1\Reference.svcmap 1 1

- / , ? , . , , - , , .

+5
3
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

, , , .


1. wdsl, .vb, :

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

2. VB Comand dll.

vbc/out:MageProxyClass.dll/t: /r:System.XML.dll,System.Web.Services.dll MageProxyClass.vb

3. , MagentoService, MageProxyClass.dll

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 
+4

- .

- ( , )

Magento.wsdl( , VS wsdl -) ProductAttributeRemove.

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

Visual Studio , " -"

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

reference.vb, .

+3

You can try in this example try

Also a more detailed C # library for Magento can be found here:

+1
source

All Articles