Home
ASP XML   Apache Proxy   PHP Reverse Proxy with Apache   Search Page  
search > ASP XML
   create account

 
    (advanced)

Howto: ASP XML

This tech note explains how to write an ASP script that will communicate with Net Research Server to retrieve XML and then render it into a page. You can also try a reverse proxy, which mirrors the entire site, using ASP.Net code such as Code Project ASP.Net script or this IIS Reverse Proxy.

Step 1: ASP Script
Create an aspx file with the same path on your IIS server as "/integration_demo/search/asp_xml.aspx" and place the following code:

<%
    Dim objXML, objXSL, sTemplate
    sTemplate = "http://demo.loopip.com/integration_demo/search/asp_xml.aspx"
    If Request.QueryString("cached") <>"" Then
        Dim strResult As String
        Dim objResponse As System.Net.WebResponse
        Dim objRequest As System.Net.WebRequest = System.Net.HttpWebRequest.Create(sTemplate & "?" & Request.ServerVariables("QUERY_STRING"))
        objResponse = objRequest.GetResponse()
        Using sr As New System.IO.StreamReader(objResponse.GetResponseStream())
            strResult = sr.ReadToEnd()
            sr.Close()
        End Using
        Response.Write(strResult)
        Response.End()
    End If
    objXML = Server.CreateObject("MSXML2.DOMDocument")
    objXML.async = False
    objXML.setProperty("ServerHTTPRequest", True)
    objXML.load(sTemplate & ".xml?hideheaders=1&" & Request.ServerVariables("QUERY_STRING"))
    objXSL = Server.CreateObject("MSXML2.DOMDocument")
    objXSL.async = False
    objXSL.setProperty("ServerHTTPRequest", True)
    objXSL.load(sTemplate & ".xsl")
    Response.Write(objXML.transformNode(objXSL))
    objXML = Nothing


 %>
Make sure the sTemplate variable contains the URL to the template you wish to use.

Step 2: Test It
Not all functionality will work without further changes to the XSLT template. You could supply an entirely new XSLT template rather than relying on the Net Research Server version. The XSLT template has already been modified to make all category URLs use a dynamic link, and use the "hideheaders" variable to skip rendering the header and sides.




 

Help build the largest human-edited directory on the Web.
Submit a Site - Open Directory Project - Become an Editor

(c) Copyright 2010, LoopIP LLC. All Rights Reserved