Re: Classic ASP to .NET WebService interfacing (Dataset to RecordSet)

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Chris Hohmann (nospam_at_thankyou.com)
Date: 03/18/05


Date: Fri, 18 Mar 2005 15:05:57 -0800


"Adam Short" <adam@phuture-uk.net> wrote in message
news:ObPbSewKFHA.3340@TK2MSFTNGP14.phx.gbl...
>I am trying to write a routine that will connect a .NET server with a
>classic ASP server.
>
> I know the following code doesn't work! The data is being returned as a
> dataset, however ASP does not recognise datasets and requires a recordset.
> Can the datatypes be converted? At the Classic ASP end or .NET end? Can
> SOAP toolkit provide the conversion, can any toolkit provide a conversion?
[snip]

Here's a proof of concept I came up with. Basically, it makes an HTTP GET
call the getEvolucionVersionList operation of your webservice, then loads
the resultant xml into a MSXML2.DomDocument and transforms the xml to html
using a XSLT style***. HTTP, XML and XSLT are all pretty standard, so this
concept should port easily to PHP, ASP.NET, JSP, etc...

[EvolucionVersionList2HTML.xsl]
<?xml version="1.0" encoding="utf-8"?>
<xsl:style*** version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="html" version="4.0" indent="yes"/>
 <xsl:template match="NewDataSet">
  <html>
   <body>
    <table>
     <tr>
      <th>RecordID</th>
      <th>ModuleName</th>
      <th>Description</th>
      <th>FileName</th>
      <th>Version</th>
      <th>Location</th>
      <th>SystemVariable</th>
      <th>DateEdited</th>
      <th>Status</th>
     </tr>
     <xsl:apply-templates select="Table"/>
    </table>
    <xsl:value-of select="count(Table)"/> Record(s)
   </body>
  </html>
 </xsl:template>
 <xsl:template match="Table">
  <tr>
   <td><xsl:value-of select="RecordID"/></td>
   <td><xsl:value-of select="ModuleName"/></td>
   <td><xsl:value-of select="Description"/></td>
   <td><xsl:value-of select="FileName"/></td>
   <td><xsl:value-of select="Version"/></td>
   <td><xsl:value-of select="Location"/></td>
   <td><xsl:value-of select="SystemVariable"/></td>
   <td><xsl:value-of select="DateEdited"/></td>
   <td><xsl:value-of select="Status"/></td>
  </tr>
 </xsl:template>
</xsl:style***>

[getEvolucionVersionList.asp]
<%
Dim url, http, xml, xsl
url =
"http://system.evolucion.co.uk/evolucion-services.asmx/getEvolucionVersionList"
Set http = CreateObject("MSXML2.ServerXMLHTTP.4.0")
http.Open "GET",url,False
http.Send
Set xml = CreateObject("MSXML2.DOMDocument.4.0")
xml.loadXML http.responseText
Set xsl = CreateObject("MSXML2.DOMDocument.4.0")
xsl.load Server.MapPath("EvolucionVersionList2HTML.xsl")
xml.transformNodeToObject xsl, Response
Set http = Nothing
Set xsl = Nothing
Set xml = Nothing
%>

NOTES:
1. I'm currently using MSXML 4.0. If you're using version 3.0 (which is
likely), you'll need to modify the asp file accordingly. For example,
"MSXML2.ServerXMLHTTP.4.0" would become "MSXML2.ServerXMLHTTP.3.0"

2. I opted not to include the SourceCode data in the html table
presentation.

3. There's nothing wrong with using SOAP to get the data instead of HTTP to
get the data as you did in your origianl code. However, you indicated that
eventually end users would need to be able to consume the service from a
number of different environments. Some of those environments may not have
SOAP, so I wanted to show that it could be done without it.

4. On a completely unrelated note, I noticed that you're using the ".inc"
extension for your include files. Also, it appears you're loading objects
into the Application scope. Here are two articles that explain why these are
not good ideas:

http://aspfaq.com/show.asp?id=2269
http://aspfaq.com/show.asp?id=2053

HTH
-Chris Hohmann


Quantcast