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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chris Hohmann

    #16
    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


    Comment

    • Adam Short

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

      Thankyou for your input, and comments.

      I am fully aware that I could use XMLRPC as you have suggested, but am
      really just looking to utilize SOAP as an alternative. More research than
      necessity, in fact to be honest I am very disappointed with SOAP on the
      whole, and wonder why anyone would implement a system which is so
      restrictive.

      In the past I have used a hacked XMLRPC procedure developed originally by
      David Carter-Tod. Although bugged, I have fixed most of them.





      "Chris Hohmann" <nospam@thankyo u.com> wrote in message
      news:eEYJW9ALFH A.1308@TK2MSFTN GP15.phx.gbl...[color=blue]
      > "Adam Short" <adam@phuture-uk.net> wrote in message
      > news:ObPbSewKFH A.3340@TK2MSFTN GP14.phx.gbl...[color=green]
      >>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:
      >
      > http://aspfaq.com/show.asp?id=2269
      > http://aspfaq.com/show.asp?id=2053
      >
      >
      > HTH
      > -Chris Hohmann
      >
      >[/color]


      Comment

      • Bob Barrows [MVP]

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

        I think MS agrees with you, given that they have deprecated that toolkit.

        Adam Short wrote:[color=blue]
        > Thankyou for your input, and comments.
        >
        > I am fully aware that I could use XMLRPC as you have suggested, but am
        > really just looking to utilize SOAP as an alternative. More research
        > than necessity, in fact to be honest I am very disappointed with
        > SOAP on the whole, and wonder why anyone would implement a system
        > which is so restrictive.
        >
        > In the past I have used a hacked XMLRPC procedure developed
        > originally by David Carter-Tod. Although bugged, I have fixed most
        > of them.
        >
        >
        >
        >
        >
        > "Chris Hohmann" <nospam@thankyo u.com> wrote in message
        > news:eEYJW9ALFH A.1308@TK2MSFTN GP15.phx.gbl...[color=green]
        >> "Adam Short" <adam@phuture-uk.net> wrote in message
        >> news:ObPbSewKFH A.3340@TK2MSFTN GP14.phx.gbl...[color=darkred]
        >>> 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 =
        >>[/color][/color]
        "http://system.evolucio n.co.uk/evolucion-services.asmx/getEvolucionVer sionLi
        st"[color=blue][color=green]
        >> 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:
        >>
        >> http://aspfaq.com/show.asp?id=2269
        >> http://aspfaq.com/show.asp?id=2053
        >>
        >>
        >> HTH
        >> -Chris Hohmann[/color][/color]

        --
        Microsoft MVP -- ASP/ASP.NET
        Please reply to the newsgroup. The email account listed in my From
        header is my spam trap, so I don't check it very often. You will get a
        quicker response by posting to the newsgroup.


        Comment

        • Adam Short

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

          I have decided to implement a sort of XML recordset system using Web
          Services to generate an XML recordset which will be pulled into an ASP ADO
          Recordset, however in all the excitement I've gone and killed my ADODB
          component on the server. There's another posting covering that!

          Once I've sorted this issue out I will begin testing the final code. If it
          works I will post it here.

          Thanks Again to everyone

          Regards

          Adam


          "Manohar Kamath" <mkamath@TAKETH ISOUTkamath.com > wrote in message
          news:%23b75e87K FHA.3992@TK2MSF TNGP15.phx.gbl. ..[color=blue]
          > Bob,
          >
          > Not really, since we still return XML that you can parse it to get back
          > results -- no different from say if you returned "plain xml." The solution
          > will not apply to all situations. I am only suggesting based on the case
          > in
          > hand.
          >
          > --
          > Manohar Kamath
          > Editor, .netWire
          > www.dotnetwire.com
          >
          >
          > "Bob Barrows [MVP]" <reb01501@NOyah oo.SPAMcom> wrote in message
          > news:erJZz37KFH A.2420@TK2MSFTN GP12.phx.gbl...[color=green]
          >> Manohar Kamath wrote:[color=darkred]
          >> > Or, you can send the XML of the ADO recordset back, and re-construct
          >> > it on the client. Use Interop on the server to work with the ADO
          >> > recordset.
          >> >
          >> > // ON THE SERVER -- Web Service
          >> > // Add references to ADODB library
          >> >
          >> > // Create a stream object
          >> > myStream = new ADODB.Stream();
          >> >
          >> > // Replace the constants with their actual values
          >> > recordSet.Save( myStream, adPersistXML);
          >> > output = myStream.ReadTe xt(adReadAll);
          >> >
          >> > // Return the XML string, complete with schema
          >> > return output;
          >> >
          >> > on the client, just re-create the disconnected recordset
          >> > http://support.microsoft.com/kb/263247
          >> >[/color]
          >> All right, I wasn't sure this was possible, so thanks for confirming that[/color]
          > it[color=green]
          >> is possible.
          >>
          >> I do appreciate that you are answering the question that was asked. But I[/color]
          > do[color=green]
          >> feel the need to express this reservation:
          >>
          >> My only issue with this solution is that it will force ALL consumers of[/color]
          > this[color=green]
          >> service to use ADO, essentially forcing any .Net apps that consume it to
          >> also use Interop to process the results. I realize that you could pass a
          >> flag indicating how the results should be returned (dataset vs recordset)
          >> but that forces the developer to maintain two sets of code that do
          >> essentially the same thing. My preference would be to simply create a[/color]
          > sparse[color=green]
          >> xml document containing the data and return that.
          >>
          >> However, if this service is intended to be consumed only by non-.Net
          >> applications, then go for it.
          >>
          >> Bob Barrows
          >>
          >> --
          >> Microsoft MVP -- ASP/ASP.NET
          >> Please reply to the newsgroup. The email account listed in my From
          >> header is my spam trap, so I don't check it very often. You will get a
          >> quicker response by posting to the newsgroup.
          >>
          >>[/color]
          >
          >[/color]


          Comment

          • Adam Short

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

            Well here it is!! The answer I think I have been looking for!!!


            First you need to get adodb.dll and insert this line of code at the top of your webservice.

            <%@ Assembly name="adodb" %>

            Then add the line;

            imports adodb

            Then the rest is history

            <webmethod()> public function testRecordSet() as ADODB.Recordset


            ' srcData = new ODBCConnection( "PROVIDER=Micro soft.Jet.OLEDB. 4.0;DATA SOURCE=" & myPath & "..\data\evoluc ion.mdb" )
            ' srcData = new ODBCConnection( "DSN=PhutureUKS ystem;uid=;pwd= " )



            ' Declare and instantiate an ADODB Connection object.
            Dim objCon As New ADODB.Connectio n
            Dim objData As New ADODB.Recordset
            Dim objStream As New ADODB.Stream

            objCon.Open ("DSN=PhutureUK System; uid=; pwd=")

            objData.Open ("EvolucionCode ", objCon, ADODB.CursorTyp eEnum.adOpenSta tic, ADODB.LockTypeE num.adLockBatch Optimistic)

            objData.Save(ob jStream, ADODB.PersistFo rmatEnum.adPers istXML)

            return objStream.ReadT ext

            'Clean up. Finally always occurs so cleanup here.
            objCon.Close()
            objData.Close()

            end function

            A recordset is returned, now all I need to do is open it up the other end!



            "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?
            >
            > =============== =============== =============== =============== =============== =======
            >
            > Web Service Code :
            > ---------------------
            >
            > dim strSelect as string
            > dim srcData as ODBCconnection
            > dim fltData as ODBCdataAdapter
            > dim myPath as String
            >
            > myPath = me.Context.Requ est.ServerVaria bles("APPL_PHYS ICAL_PATH")
            >
            >
            > dim rtnData as DataSet
            >
            > strSelect = "SELECT * FROM myDataSource"
            >
            > ' srcData = new ODBCConnection( "PROVIDER=Micro soft.Jet.OLEDB. 4.0;DATA
            > SOURCE=" & myPath & "..\data\myData Source.mdb" )
            >
            > srcData = new ODBCConnection( "DSN=MyDataSour ce;uid=;pwd=" )
            >
            > fltData = new ODBCdataAdapter ( strSelect, srcData )
            >
            > rtnData = new dataset
            >
            > fltData.fill( rtnData )
            >
            > return rtnData
            >
            > =============== =============== =============== =============== =============== =======
            >
            > ASP Web Server Code:
            > -------------------------
            >
            > SET objSoapClient = Server.CreateOb ject("MSSOAP.So apClient")
            >
            >
            > ' needs to be updated with the url of your Web Service WSDL and is
            > ' followed by the Web Service name
            >
            > objSoapClient.C lientProperty(" ServerHTTPReque st") = True
            >
            > Call
            > objSoapClient.m ssoapinit("http ://system.evolucio n.co.uk/evolucion-services.asmx?W SDL")
            >
            > set RecordSet = Server.CreateOb ject("ADODB.Rec ordset")
            >
            > ' use the SOAP object to call the Web Method Required
            > RecordSet = objSoapClient.g etEvolucionVers ionList()
            >
            > strOutput = strOutput & "<P>On-Line Result : " & RecordSet.Recor dCount
            >
            > =============== =============== =============== =============== =============== =======
            >
            >[/color]

            Comment

            Working...