Visual Basic 6.0 和 MagentoSoap 的问题

问题描述 投票:0回答:1

一段时间以来,我一直致力于在 Visual Basic 6 中制作一个可以与 magento-Soap-Inferface “对话”的工具。

我正在使用以下版本: - Magento 版本 1.5.0.0 - 适用于 Visual Basic 6 的 Microsoft Soap Tookit 3.0

用 VB 编码,如下所示:

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

我运行并出错

运行时错误'-2147467259(80004004) SoapMapper:找不到 SoapMapper 映射的目标命名空间为 http://xml.apache.org/xml-soap 的模式定义 HRESULT=0x80004005:未指定错误 - Soap Mapper:无法为命名空间 http://xml.apache.org/xml-soap 中 Map 类型的数组元素创建映射器。 HRESULT=0x80004005:未指定的错误 - SoapMapper:将数据恢复到 SoapMapper anyType 失败。

我已经描述过,只有当我返回anyType 或fixedArray 时,问题才会出现。

请帮助我。

php magento soap vb6 magento-soap-api
1个回答
0
投票

这表示 xml 请求架构与预期不匹配。 不需要代理com

这里是例子

添加对 Microsoft Xml 2.0 或更高版本的引用

检查该方法

 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

在 url 服务中输入 asmx Web 服务的 url:如何 http://myserver/serviceinterface/serviceinterface.asmx

在肥皂行动中,首先对您服务中的某些方法进行了修改,然后查看了定义。其中存在一个调用 SoapAction 的标签,SOAPAction 的一些方式:“http://localhost/commonxmlschemas/technology/createcharge”(仅示例)

您也看到了肥皂请求

 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>

复制自

  <?xml to </soap:Envelope> 

它是 xmlRequest 参数,现在只填充该 xmlRequest 上的参数并将其发送到 PostRequest 方法

很简单,不是吗?

© www.soinside.com 2019 - 2024. All rights reserved.