ASP.NET
  Home arrow ASP.NET arrow Page 4 - Using XML Web Services in Traditional ASP
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

Using XML Web Services in Traditional ASP
By: Luke Niland
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 5
    2007-08-07

    Table of Contents:
  • Using XML Web Services in Traditional ASP
  • Looking at the XML
  • Formatting the Data Using XSL
  • Putting it all Together

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Using XML Web Services in Traditional ASP - Putting it all Together


    (Page 4 of 4 )

    Now we should have all the building blocks we need to actually output the contents of the XML file via the XSL to the browser. We will do this in a very simple traditional ASP function, using the MSXML component library. Make sure the web server you are running the code from has the MSXML component installed.

    The Function

    This is the actual function you need to put in your ASP page.

    <%

    Function getFlickrXML(flickrUrl, xslSheet)

       dim styleFile

       dim source1, style

       styleFile = Server.MapPath(xslSheet)

     

       dim xmlhttp

       set xmlhttp = Server.CreateObject("Microsoft.XMLHTTP")

       xmlhttp.Open "GET", flickrUrl, false

       xmlhttp.Send

      

       set source1 = Server.CreateObject("Microsoft.XMLDOM")

       source1.async = false

       source1.loadxml(xmlhttp.ResponseText)

     

       set style = Server.CreateObject("Microsoft.XMLDOM")

       style.async = false

       style.load(styleFile)

     

       Response.Write source1.transformNode(style)

       set source1 = nothing

       set style = nothing

       set xmlhttp = nothing

    End Function

    %>

     

    This function should be very open ended, and work with any service, not just Flickr as we are passing it both the URL from which to get the information, and the style sheet to use.

    All it does is create an XMLHTTP object and get the data from the URL you passed into the function. It then loads the XSL style file you send it into a XMLDOM object.

    Then, using response.write and the transformNode function, it writes out the content of the XML file in a format based on what's in the XSL file.

    To call the function, pass it the URL and the name of the XSL. In our example your actual code would look something like this.

    <table width="100%" border="0">

                       

    <%= getFlickrXML("http://www.flickr.com/services/rest/?
    method=flickr.photosets.getPhotos&api_key=[your_api_key&photoset_id=
    [your_set_id]","flickr-lists.xsl")%></td>

     

    </table>

    Save your ASP and XSL file onto your web server in the same folder, browse to the ASP file and if all has worked, you should see all the photos from your set, in a table 7 columns across, all with clickable links to the photo's page on Flickr.com


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · if server.CreateObject("microsoft.xmlhttp") is used in asp, pages can seem to hang...
     

    ASP.NET ARTICLES

    - Disadvantages of the ASP.NET MVC Framework
    - Advantages of the ASP.NET MVC Approach
    - ASP.NET Web Forms Weaknesses
    - ASP.NET Web Forms Meets ASP.NET MVC
    - Source Code for Saving and Retrieving Data w...
    - Using GridView to Save and Retrieve Data wit...
    - Handling Dynamic Images in ASP.NET 3.5 AJAX ...
    - Retrieving Data with AJAX and the GridView C...
    - Playing with Images in ASP.NET 3.5 AJAX Appl...
    - Saving and Retrieving Data with AJAX
    - Enhancing PHP Via the ASP.NET AJAX Framework...
    - Enhancing PHP Programming with the ASP.NET A...
    - Classes and ASP.NET AJAX
    - Using ASP.NET AJAX
    - Building a Simple Storefront with LINQ

     
    Application Delivery: Everything You Wanted to Know, but Didn`t Know You Needed to Ask
    A comprehensive guide to examining the topics of Wide-area Data Services and app....

     
    Best Practices: Safe and Secure Hardware Asset Recovery
    Companies increasingly must meet EPA and local requirements for the disposal of ....

     
    Managing SSL Security in Multi-Server Environments
    Read this white paper to learn how to simplify management of your organization's....

     
    Open Source Security Myths
    Open Source Software (OSS) is computer software whose source code is available t....

     
    Power and Cooling Capacity Management for Data Centers
    This paper describes the principles for achieving power and cooling capacity man....

     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
    Stay green...Green IT