如何在Visual Basic中发布请求并获取响应(解析响应)

时间:2019-02-16 12:06:22

标签: xml request response basic

我曾尝试使用Visual Basic进行发布请求,但是代码不起作用。 也许有人发现了错误?

    Dim strURL As String
    Dim objHTTP
    Dim myxml As String
    Dim xmlhttpResponse As New Xml.XmlDocument

    myxml = "<?xml version=""1.0"" encoding=""UTF-8""?>" & _
            "<findItemsByKeywordsRequest xmlns=""http://www.ebay.com/marketplace/search/v1/services"">" & _
            "<keywords>potter</keywords>" & _
     "</findItemsByKeywordsRequest>"

    strURL = "https://svcs.ebay.com/services/search/FindingService/v1"

    objHTTP = CreateObject("Microsoft.xmlhttp")

    objHTTP.Open("POST", strURL, False)
    objHTTP.setRequestHeader("X-EBAY-SOA-SECURITY-APPNAME", "xxxxxxxxxxxxxxxxxxxxxxxx")
    objHTTP.setRequestHeader("X-EBAY-SOA-OPERATION-NAME", "findItemsByKeywords")
    objHTTP.send(myxml)

    xmlhttpResponse = objHTTP.responseXML
    xmlhttpRoot = xmlhttpResponse.DocumentElement
    XMLResponse = objHTTP.responseText
    MsgBox(XMLResponse)
    xmlhttpResponse = objHTTP.responseXML
End Sub

0 个答案:

没有答案