Solved http request and response

Posted on 2007-08-01
Last Modified: 2013-11-19
I am trying to convert the following Access 2003 code into 2.0
Thanks in advance for any help.

Any Ideas?
Function CallAPI(strXML As Variant)
Dim objXMLHTTP, dblqte As String
' Build the XML Open statement & Header Info
Set Misc = CurrentDb.OpenRecordset("Misc")
url = Trim(Misc![url])
uname = Trim(Misc![username])
pwd = Trim(Misc![password])
url = url & strXML
' Call the XMLHTTP Library functions
Set objXMLHTTP = CreateObject("Microsoft.XMLHTTP")
objXMLHTTP.Open "POST", url, False, uname, pwd
objXMLHTTP.SetRequestHeader "Content-type", "application/x-www-form-urlencoded"
'Debug.Print objXMLHTTP.ResponseText
CallAPI = objXMLHTTP.ResponseText
End Function
Question by:dbsoracle
    LVL 18

    Expert Comment


    It would be something like this , though you can change the local path to an URL instead  
    and read the data into a datatable

      Private Sub Getdata()

         Dim ds As New DataSet()

            Dim reader As XmlTextReader = New System.Xml.XmlTextReader("C:\test.xml")

            Dim dtbl As New DataTable
            Dim dr As DataRow
            Dim dv As New DataView(dtbl)

            Dim objNodes As New System.Xml.XmlDocument
            Dim oNodes As System.Xml.XmlNodeList
            'set the parent node from where you want to start to read the child nodes.
            oNodes = objNodes.SelectNodes("//spot")

            dtbl.Columns.Add(New DataColumn("col1", GetType(String)))
            dtbl.Columns.Add(New DataColumn("col2", GetType(String)))

            Dim node As System.Xml.XmlNode

            For Each node In oNodes

                dr = dtbl.NewRow()
                dr(0) = node.Attributes.GetNamedItem("id").Value
                dr(1) = node.Attributes.GetNamedItem("num").Value
                'dr(1) = node.Item("file").InnerText 'regular node reading

        End Sub

    hope this helps


    Author Comment

    Hi VBTurbo:
    Thanks much for responding.  The Access code actually calls a web service over the internet and that web service returns xml. In digging through .net, I think I need the HttpWebRequest and HttpWebResponse object. In order to call the web service, I also need to pass in user/password and I dont know how to attach that to the HttpWebRequest object, or possibly use .net's web services...???

    Thanks much.
    LVL 18

    Expert Comment

    well here is a link regarding HttpWebRequest and sending credentials to the server ,though regarding webservice's my knowledge is zero

    HttpWebRequest Class
    WebRequest.PreAuthenticate Property

    And the IAuthenticationModule.Authenticate Method

    LVL 18

    Accepted Solution


    HttpWebRequest Class
    WebRequest.PreAuthenticate Property

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL ( several years ago, it seemed like now was a good time to updat…
    SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
    Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
    Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now