Re: Classic ASP to .NET WebService interfacing (Dataset to RecordSet)
"Adam Short" <adam@phuture-uk.net> wrote in message
news:ObPbSewKFH A.3340@TK2MSFTN GP14.phx.gbl...[color=blue]
>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?[/color]
[snip]
Here's a proof of concept I came up with. Basically, it makes an HTTP GET
call the getEvolucionVer sionList operation of your webservice, then loads
the resultant xml into a MSXML2.DomDocum ent and transforms the xml to html
using a XSLT stylesheet. HTTP, XML and XSLT are all pretty standard, so this
concept should port easily to PHP, ASP.NET, JSP, etc...
[EvolucionVersio nList2HTML.xsl]
<?xml version="1.0" encoding="utf-8"?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="4.0" indent="yes"/>
<xsl:template match="NewDataS et">
<html>
<body>
<table>
<tr>
<th>RecordID</th>
<th>ModuleNam e</th>
<th>Description </th>
<th>FileName</th>
<th>Version</th>
<th>Location</th>
<th>SystemVaria ble</th>
<th>DateEdite d</th>
<th>Status</th>
</tr>
<xsl:apply-templates select="Table"/>
</table>
<xsl:value-of select="count(T able)"/> Record(s)
</body>
</html>
</xsl:template>
<xsl:template match="Table">
<tr>
<td><xsl:valu e-of select="RecordI D"/></td>
<td><xsl:valu e-of select="ModuleN ame"/></td>
<td><xsl:valu e-of select="Descrip tion"/></td>
<td><xsl:valu e-of select="FileNam e"/></td>
<td><xsl:valu e-of select="Version "/></td>
<td><xsl:valu e-of select="Locatio n"/></td>
<td><xsl:valu e-of select="SystemV ariable"/></td>
<td><xsl:valu e-of select="DateEdi ted"/></td>
<td><xsl:valu e-of select="Status"/></td>
</tr>
</xsl:template>
</xsl:stylesheet>
[getEvolucionVer sionList.asp]
<%
Dim url, http, xml, xsl
url =
"http://system.evolucio n.co.uk/evolucion-services.asmx/getEvolucionVer sionList"
Set http = CreateObject("M SXML2.ServerXML HTTP.4.0")
http.Open "GET",url,F alse
http.Send
Set xml = CreateObject("M SXML2.DOMDocume nt.4.0")
xml.loadXML http.responseTe xt
Set xsl = CreateObject("M SXML2.DOMDocume nt.4.0")
xsl.load Server.MapPath( "EvolucionVersi onList2HTML.xsl ")
xml.transformNo deToObject 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.ServerX MLHTTP.4.0" would become "MSXML2.ServerX MLHTTP.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:
HTH
-Chris Hohmann
"Adam Short" <adam@phuture-uk.net> wrote in message
news:ObPbSewKFH A.3340@TK2MSFTN GP14.phx.gbl...[color=blue]
>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?[/color]
[snip]
Here's a proof of concept I came up with. Basically, it makes an HTTP GET
call the getEvolucionVer sionList operation of your webservice, then loads
the resultant xml into a MSXML2.DomDocum ent and transforms the xml to html
using a XSLT stylesheet. HTTP, XML and XSLT are all pretty standard, so this
concept should port easily to PHP, ASP.NET, JSP, etc...
[EvolucionVersio nList2HTML.xsl]
<?xml version="1.0" encoding="utf-8"?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="4.0" indent="yes"/>
<xsl:template match="NewDataS et">
<html>
<body>
<table>
<tr>
<th>RecordID</th>
<th>ModuleNam e</th>
<th>Description </th>
<th>FileName</th>
<th>Version</th>
<th>Location</th>
<th>SystemVaria ble</th>
<th>DateEdite d</th>
<th>Status</th>
</tr>
<xsl:apply-templates select="Table"/>
</table>
<xsl:value-of select="count(T able)"/> Record(s)
</body>
</html>
</xsl:template>
<xsl:template match="Table">
<tr>
<td><xsl:valu e-of select="RecordI D"/></td>
<td><xsl:valu e-of select="ModuleN ame"/></td>
<td><xsl:valu e-of select="Descrip tion"/></td>
<td><xsl:valu e-of select="FileNam e"/></td>
<td><xsl:valu e-of select="Version "/></td>
<td><xsl:valu e-of select="Locatio n"/></td>
<td><xsl:valu e-of select="SystemV ariable"/></td>
<td><xsl:valu e-of select="DateEdi ted"/></td>
<td><xsl:valu e-of select="Status"/></td>
</tr>
</xsl:template>
</xsl:stylesheet>
[getEvolucionVer sionList.asp]
<%
Dim url, http, xml, xsl
url =
"http://system.evolucio n.co.uk/evolucion-services.asmx/getEvolucionVer sionList"
Set http = CreateObject("M SXML2.ServerXML HTTP.4.0")
http.Open "GET",url,F alse
http.Send
Set xml = CreateObject("M SXML2.DOMDocume nt.4.0")
xml.loadXML http.responseTe xt
Set xsl = CreateObject("M SXML2.DOMDocume nt.4.0")
xsl.load Server.MapPath( "EvolucionVersi onList2HTML.xsl ")
xml.transformNo deToObject 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.ServerX MLHTTP.4.0" would become "MSXML2.ServerX MLHTTP.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:
HTH
-Chris Hohmann
Comment