2012-08-23 10 views
5

से Magento API को कैसे कॉल करें Magento में एक एपीआई है और ऐसा लगता है कि कुछ लोग इसे VB.NET के माध्यम से उपयोग कर रहे हैं लेकिन मैं इसे कई घंटों तक प्रयास करने के बाद काम नहीं कर सकता।वीबीएनईटी

मैं Magento पर 1.7.0.2 एपीआई के साथ काम कर रहे वीबी.NET ऐप को प्राप्त करने का प्रयास कर रहा हूं। मैं डब्ल्यूएस-आई अनुपालन वेब सेवा सेटिंग का उपयोग कर रहा हूं।

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:\Documents\Visual Studio 2010\Projects\Mage\Mage\My Project\Settings.settings 1 1 Mage

यदि मैं इसे सेवा संदर्भ (वेब ​​संदर्भ के बजाए) जोड़ने की कोशिश करता हूं तो मुझे त्रुटियों का एक अलग सेट मिलता है। बाध्यकारी wsdl आयात नहीं कर सकता:

wsdl आयात नहीं कर सकते बंदरगाह 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:\Documents\Visual Studio 2010\Projects\Mage\Mage\Service References\ServiceReference1\Reference.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:\Documents\Visual Studio 2010\Projects\Mage\Mage\Service References\ServiceReference1\Reference.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:\Documents\Visual Studio 2010\Projects\Mage\Mage\Service References\ServiceReference1\Reference.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:\Documents\Visual Studio 2010\Projects\Mage\Mage\Service References\ServiceReference1\Reference.svcmap 1 1 Mage

कोई मुझे कैसे एक फोन करना और एक परिणाम प्राप्त करने के लिए पर बहुत स्पष्ट अनुदेश/कोड दे सकते हैं? मुझे प्रारंभिक कॉन्फ़िगरेशन सही भी नहीं लग रहा है। मैंने कुछ कोड डाउनलोड किए हैं जो दूसरों ने ऑनलाइन प्रदान किए हैं, लेकिन यदि काम नहीं करता है - शायद इसलिए कि यह पहले के संस्करण के लिए था।

+3

क्या आप ब्राउज़र में वेब सेवा देख सकते हैं? – Kiddo

+4

हाँ, मैं एक परीक्षण स्थल यहाँ है: http://testshop.tokyorealtime.com/api/v2_soap?wsdl=1 मुझे लगता है कि कुछ एपीआई एक्सएमएल, या कुछ और नेट के साथ थोड़ा असंगत के साथ गलत हो सकता है, फिर भी ऐसा लगता है कि अन्य लोग इसे काम करने में कामयाब रहे हैं। –

उत्तर

4
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 

कि कोड obviously- में सुधार करने की जरूरत है मैं आबिद हुसैन के लिंक

1. मैं फोन करके एक .vb स्रोत फ़ाइल बनाई wdsl उपकरण का उपयोग से इस सामान


सुंदर बनाना करने के समय नहीं मिला है:

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

2. बाद में मैं एक dll में sourcefile संकलित करने के लिए वीबी cOMAND लाइन संपादक हुआ करता था।

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

पोस्ट करने से पहले मैंने इन निर्देशों का पालन किया था, लेकिन वे काम नहीं कर पाए। किसी भी डीएलएल में कोड को संकलित करने की आवश्यकता नहीं है, वैसे भी इसे किसी भी VB.NET प्रोजेक्ट में एक्सेस करें। क्या आप वास्तव में इसे काम करने के लिए मिला? मैं एक नया बक्षीस बनाने जा रहा हूं क्योंकि यद्यपि स्टैक ओवरफ्लो स्वचालित रूप से आपको अंक से सम्मानित करता है, मेरी समस्या समाधान के बिना बनी हुई है। –

+1

अब काम कर रहा प्रतीत होता है कि मैंने वीबी 2013 में अपग्रेड किया –

3

अंत:

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

3. अंत में मैं

Private WithEvents msvc As New MagentoService() 

4. उदाहरण मेरी MageProxyClass.dll में परिभाषित MagentoService वर्ग का एक उदाहरण बनाने के लिए कर रहा था यह काम कर रहा है।

हमेशा की तरह अपने वेब सेवा जोड़े

ओपन Magento (यह संकलन लेकिन यह वैसे भी जोड़ने के लिए असफल हो जायेगी)।wsdl (या जो भी आपके वीएस ने आपके वेब संदर्भ में wsdl फ़ाइल को बुलाया है) और CatalogProductAttribute को कॉल को पूरी तरह से हटा दें।

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

आग अप दृश्य स्टूडियो कमांड प्रॉम्प्ट और, अपनी परियोजना पर जाएं, फिर "वेब संदर्भ"

प्रकार: wsdl/भाषा: वीबी /out:Reference.vb Magento.wsdl/नाम स्थान: com.yourwebservicename.www

यह सही ढंग से संदर्भ.vb फ़ाइल उत्पन्न करेगा जिसे आपको जारी रखने की आवश्यकता है।