Read REST service using ASP

Tagged with rest ASP vb

Language: ASP

View as text

<% option explicit %>

<!-- references
http://www.4guysfromrolla.com/webtech/110100-1.2.shtml
http://www.4guysfromrolla.com/webtech/070302-1.shtml
http://dotnetjunkies.com/Tutorial/99CA4563-FBD4-411F-A9C6-FF9E8A0E664F.dcik
http://www.codeproject.com/asp/googleapisinasp.asp
http://www.devguru.com/Technologies/xmldom/QuickRef/obj_nodeList.html
http://www.thescripts.com/forum/thread125470.html
http://www.codeproject.com/soap/ConsumWebServicefromASP.asp
http://aspfree.com/authors/123aspx/WSDLFromASP/


-->

<% Dim objRequest, objXMLDoc, objXmlNode, strRet, strError
Set objRequest = Server.createobject("MSXML2.XMLHTTP")
'on error resume next
With objRequest
.open "GET", "HTTP://137.28.186.63:3000/recipes.xml", False
.setRequestHeader "Content-Type", "text/xml"
.send
End With


if err.number = 0 then

    
    Set objXMLDoc = Server.createobject("Microsoft.XMLDOM")
    objXmlDoc.async = false
    
    
    If objXMLDoc.LoadXml(objRequest.ResponseText) Then
        dim objLst,item
        Set objLst = objXMLDoc.getElementsByTagName("recipe")
        
        for each item in objLst
            response.write "<p>"
            'response.write item.childnodes(0).text & "<br />"
            'response.write item.childnodes(1).text & "<br />"
             response.write item.childnodes(4).text & "<br />"
            response.write "<pre>" & item.childnodes(2).text &  "</pre><br />"
           
            response.write item.childnodes(3).text & "<br />"
            
            'response.write item.childnodes(5).text & "<br />"
          
            response.write "</p>"
        next
        
       
       
       
       
    else
      response.write "Unable to get a response"
    end if
    
else
  response.write("Unable to contact the source.")
end if

%>
Original snippet written by Brian Hogan
Last updated at 07:00 AM on Feb 02, 2009 by Brian Hogan

SnippetStash costs money to host and develop. The service is free for everyone to use
but if you found it useful please consider making a small donation.