Problems with Visual Basic 6.0 and MagentoSoap

2019-08-23 04:05发布

问题:

since some time I am working to make a tool in in Visual Basic 6 which can ‘talk’ with the magento-Soap-Inferface.

I am using the following versions: - Magento in Version 1.5.0.0 - Microsoft Soap Tookit 3.0 for Visual Basic 6

coding in VB like here :

Private Sub Command1_Click()
  Dim paramstring As String
  Dim soapClient, sessionID
  Dim attributeSets() As returnData

  Set soapClient = CreateObject("MSSOAP.SoapClient30")   
  soapClient.MSSoapInit "http://localhost/magento/index.php/api/soap/?wsdl"
  sessionID = soapClient.login("dede", "1q2w3e4r5t6y7u")
  attributeSets = soapClient.call(sessionID, "product_attribute_set.list", 0)    
End Sub

i running and error

Run-time error '-2147467259(80004004) SoapMapper:The schema definision with a targetnamespace of http://xml.apache.org/xml-soap for SoapMapper Map cound not be found HRESULT=0x80004005:Unspecified error - Soap Mapper : can't create mapper for array element of type Map in namespace http://xml.apache.org/xml-soap. HRESULT=0x80004005:Unspecified error - SoapMapper : Restoring data into SoapMapper anyType Failed.

How I have described, the problem comes only up when I get back anyType or fixedArray.

Please help me.

回答1:

This is saying the xml request schema does not match the expected. Proxy com is not necessary

here example

Add reference to Microsoft Xml, version 2.0 or higher

Check that method

 Public Function PostRequest(urlService As String, soapAction As String, xmlRequest As String) As String

   Dim oHttReq  As XMLHTTPRequest
   Dim Log      As Logger
   Dim w        As w32
   Dim filepath As String
   Dim response As String

   Set oHttReq = New XMLHTTPRequest

   oHttReq.open "POST", urlService, False
   oHttReq.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
   oHttReq.setRequestHeader "SOAPAction", soapAction
   oHttReq.send xmlRequest       

   PostRequest = oHttReq.responseText

   If Not oHttReq Is Nothing Then
     Set oHttReq = Nothing
   End If       

 End Function

in url service put url of the asmx web service: some how http://myserver/serviceinterface/serviceinterface.asmx

in soap action first taked a revised to some method in you service and after see to the definition. In that exist a tag call SoapAction, some how SOAPAction: "http://localhost/commonxmlschemas/technology/createcharge" (only example)

you also are seeing the soap request

 POST /myserver/serviceinterface/serviceinterface.asmx HTTP/1.1
 Host: myserver
 Content-Type: text/xml; charset=utf-8
 Content-Length: length
 SOAPAction: "http://localhost/commonxmlschemas/technology/createcharge"

 <?xml version="1.0" encoding="utf-8"?>
 <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Header>
     <RequestHeader xmlns="http://localhost/commonxmlschemas/technology/">
       <Headers>
         <anyType />
         <anyType />
       </Headers>
     </RequestHeader>
   </soap:Header>
   <soap:Body>
     <createcharge xmlns="http://localhost/commonxmlschemas/technology/">
       <chargeRequest xmlns="http://localhost/commonxmlschemas/technology/chargeRequest.xsd">
         <charge>
           <creditcard xmlns="http://localhost/commonxmlschemas/technology/Charge.xsd">string</creditcard>
           <amount xmlns="http://localhost/commonxmlschemas/technology/Charge.xsd">int</amount>
         </charge>
         <Tag>string</Tag>
       </chargeRequest>
     </createcharge>
   </soap:Body>
 </soap:Envelope>

copy from

  <?xml to </soap:Envelope> 

it is the xmlRequest parameter now only fill the parameters on that xmlRequest and send it to the PostRequest Method

simple, no?