SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist cms9651's Avatar
    Join Date
    Mar 2010
    Posts
    407
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    ASP page with the Object Msxml2

    Hi there everybody.

    I hope your help.

    If execute in the browser this web page's I don't have problem, the output working.

    The page #1 generate the CSV file and the page #2 execute the download of CSV file.
    Code:
    http://www.myNet.com/Rep.htm?id=20&Fto=CSV
    http://www.myNet.com/dynamic/servlet?id=20&fto=CSV&filepath=/files/816.xml
    Now I need execute this web page's into ASP page with the Object Msxml2 and write this code.

    Here is my problem.
    1. The page #1 not generate the CSV file;
    2. The page #2 not download the CSV file;
    3. Microsoft VBScript runtime error '800a0035' : File not found

    Your help would be very appreciated.
    Thanks for your time and hints.

    Cheers.
    Code:
    <%
    
            Set objSrvHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP.6.0")
            Set objXMLSend = Server.CreateObject("Msxml2.DOMDocument.6.0")
            Set objXMLReceive = Server.CreateObject("Msxml2.DOMDocument.6.0")
            objXMLSend.async = false
            objXMLSend.loadXML ("<msg><id>2</id></msg>")   
            objSrvHTTP.open "POST","http://www.myNet.com/Rep.htm?id=20&Fto=CSV",false
            objSrvHTTP.send objXMLSend
            Response.ContentType = "text/xml"
            Response.Write objXMLReceive.xml
    
            Set oFso = CreateObject("Scripting.FileSystemObject")      
    
            sDestinationFile = "http://www.myNet.com/dynamic/servlet?id=20&fto=CSV&filepath=/files/816.xml"
    
            strFilePath = sDestinationFile
    
            Set oFile = oFso.GetFile(strFilePath)
                    
            strFileName = UCase(oFile.Name) 
            strFileSize = CLNG(oFile.size) 
            
            Set oFile = Nothing 
            Set oFso = Nothing 
    
            Const adTypeBinary = 1 
    
            Response.Clear 
    
            Set objStream = Server.CreateObject("ADODB.Stream") 
            objStream.Open 
            objStream.Type = adTypeBinary 
            objStream.LoadFromFile strFilePath 
    
            strFileType = lcase(Right(strFileName, 4)) 
         
        Select Case strFileType 
            Case ".asf" 
                ContentType = "video/x-ms-asf" 
            Case ".avi" 
                ContentType = "video/avi" 
            Case ".doc" 
                ContentType = "application/msword" 
            Case ".zip" 
                ContentType = "application/zip" 
                ContentType = "application/x-zip-compressed" 
            Case ".xls" 
                ContentType = "application/vnd.ms-excel" 
            Case ".gif" 
                ContentType = "image/gif" 
            Case ".jpg", "jpeg" 
                ContentType = "image/jpeg" 
            Case ".wav" 
                ContentType = "audio/wav" 
            Case ".mp3" 
                ContentType = "audio/mpeg3" 
            Case ".mpg", "mpeg" 
                ContentType = "video/mpeg" 
            Case ".rtf" 
                ContentType = "application/rtf" 
            Case ".htm", "html" 
                ContentType = "text/html" 
            Case ".asp" 
                ContentType = "text/asp" 
            Case Else 
                ContentType = "application/octet-stream" 
        End Select 
         
        Response.AddHeader "Content-Disposition", "attachment; filename=" & strFileName 
        Response.AddHeader "Content-Length", strFileSize 
    
        Response.Charset = "UTF-8" 
        Response.ContentType = ContentType 
         
        Do While Not objStream.EOS 
            Response.BinaryWrite objStream.Read(8192)
            Response.Flush 
        Loop 
    
        objStream.Close 
        Set objStream = Nothing
    
    %>
    Thanks you very much for your help
    I'm really happy for your quickly answer.
    Good bye

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Oct 2001
    Location
    Vancouver BC Canada
    Posts
    2,029
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    It has been at least half a dozen years since I wrote code like this so I'm a bit rusty but I believe it is because your script can't find the XML file to open.

    Code:
    sDestinationFile = "http://www.myNet.com/dynamic/servlet?id=20&fto=CSV&filepath=/files/816.xml"
    sDestinationFile needs to be a file on your server (with a physical path like c:/inetpub/data/816.xml) otherwise the FileScripting Object can't read it... Even if you download it to a place on your server temporarily and then process it.
    Andrew Wasson | www.lunadesign.org
    Principal / Internet Development

  3. #3
    SitePoint Evangelist cms9651's Avatar
    Join Date
    Mar 2010
    Posts
    407
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    thanks for answer.
    You know another way to resolve my problem?
    Thanks you very much for your help
    I'm really happy for your quickly answer.
    Good bye

  4. #4
    SitePoint Wizard bronze trophy
    Join Date
    Oct 2001
    Location
    Vancouver BC Canada
    Posts
    2,029
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Well, the only way the Filesystem Object is going to work is if the file is on the same physical server as your script so you'll have to download the file to a location on your server and then use your script to process it.

    Here's some information about it from Microsoft: http://support.microsoft.com/kb/276011
    Andrew Wasson | www.lunadesign.org
    Principal / Internet Development


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •