msxml2.serverXMLhttp and response.binarywrite

Discussion in 'ASP General' started by katrinaVictim@., Oct 16, 2005.

  1. Question:
    I get the eror listed at the bottom of the post. What can I do to
    make the response of the x1.send a "binary" type? Or, in general,
    how can I just "make this work"?

    <%@ Language=VBScript %>
    <%
    Response.Buffer = TRUE
    Response.ContentType = "image/jpg"

    Set x1 = Server.CreateObject("Msxml2.ServerXMLHTTP")
    x1.open "GET", "[http link to your favorite image.jpg]", FALSE
    x1.send

    Response.BinaryWrite x1.responsestream
    set x1 = nothing
    %>


    Error is returned below:

    'Response object error 'ASP 0106 : 80020005'
    'Type Mismatch
    '/scraps/getGraphic.asp, line 10
    'An unhandled data type was encountered.
     
    katrinaVictim@., Oct 16, 2005
    #1
    1. Advertising

  2. <katrinaVictim@.> wrote in message
    news:...
    > Question:
    > I get the eror listed at the bottom of the post. What can I do to
    > make the response of the x1.send a "binary" type? Or, in general,
    > how can I just "make this work"?
    >
    > <%@ Language=VBScript %>
    > <%
    > Response.Buffer = TRUE
    > Response.ContentType = "image/jpg"
    >
    > Set x1 = Server.CreateObject("Msxml2.ServerXMLHTTP")
    > x1.open "GET", "[http link to your favorite image.jpg]", FALSE
    > x1.send
    >
    > Response.BinaryWrite x1.responsestream
    > set x1 = nothing
    > %>
    >
    >
    > Error is returned below:
    >
    > 'Response object error 'ASP 0106 : 80020005'
    > 'Type Mismatch
    > '/scraps/getGraphic.asp, line 10
    > 'An unhandled data type was encountered.


    Try:

    Response.BinaryWrite x1.responsestream.Read()


    -Mark
     
    Mark J. McGinty, Oct 16, 2005
    #2
    1. Advertising

  3. katrinaVictim@.

    Roland Hall Guest

    <katrinaVictim@.> wrote in message
    news:...
    : Question:
    : I get the eror listed at the bottom of the post. What can I do to
    : make the response of the x1.send a "binary" type? Or, in general,
    : how can I just "make this work"?
    :
    : <%@ Language=VBScript %>
    : <%
    : Response.Buffer = TRUE
    : Response.ContentType = "image/jpg"
    :
    : Set x1 = Server.CreateObject("Msxml2.ServerXMLHTTP")
    : x1.open "GET", "[http link to your favorite image.jpg]", FALSE
    : x1.send
    :
    : Response.BinaryWrite x1.responsestream
    : set x1 = nothing
    : %>
    :
    :
    : Error is returned below:
    :
    : 'Response object error 'ASP 0106 : 80020005'
    : 'Type Mismatch
    : '/scraps/getGraphic.asp, line 10
    : 'An unhandled data type was encountered.

    Some routines to help you. Get the image via HTTPRequest, save it and
    reload it.

    http://kiddanger.com/lab/getaspimage.asp

    View the source with your browser to see how the file is called. Then click
    on the link at the bottom of the page 'view source' to view the source of
    the file that does the work.

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
     
    Roland Hall, Oct 17, 2005
    #3
  4. On Sun, 16 Oct 2005 01:50:25 -0500, "McKirahan" <>
    wrote:

    ><katrinaVictim@.> wrote in message
    >news:...
    >> Question:
    >> I get the eror listed at the bottom of the post. What can I do to
    >> make the response of the x1.send a "binary" type? Or, in general,
    >> how can I just "make this work"?
    >>
    >> <%@ Language=VBScript %>
    >> <%
    >> Response.Buffer = TRUE
    >> Response.ContentType = "image/jpg"
    >>
    >> Set x1 = Server.CreateObject("Msxml2.ServerXMLHTTP")
    >> x1.open "GET", "[http link to your favorite image.jpg]", FALSE
    >> x1.send
    >>
    >> Response.BinaryWrite x1.responsestream
    >> set x1 = nothing
    >> %>
    >>
    >>
    >> Error is returned below:
    >>
    >> 'Response object error 'ASP 0106 : 80020005'
    >> 'Type Mismatch
    >> '/scraps/getGraphic.asp, line 10
    >> 'An unhandled data type was encountered.
    >>

    >
    >Try xl.ResponseBody
    >
    >
    >You can read the response using one of four properties.
    > responseBody
    > responseStream
    > responseText
    > responseXML
    >http://www.eggheadcafe.com/articles/20010114.asp
    >
    >
    >ResponseBody Variant array
    > Returns the body of the response as an array.
    >ResponseStream IStream
    > Returns the body of the response as an ADO Stream object.
    >ResponseText String
    > Returns the body of the response as a text string.
    >ResponseXML XMLDocument Object
    > Returns the body of the response as parsed by the MSXML XMLDOM parser.
    >http://www.sxlist.com/techref/language/asp/wwwextract.htm
    >


    You're correct. Response.body does return the graphic to the browser
    if NO html surrounds the functional code.

    I had left in the <html><body>....</body></html> tags around the
    VBScript above before I posted to the newsgroup (whoops), and when
    doing this the browser then interprets the content as "text". Try
    putting in a mere <html> tag before the code and you'll get a bunch of
    extended ascii and stuff in the browser when using responseBody.

    See, here's my issue. I have graphics that are availabe on an
    e-commerce drop ship suppliers web server. There are huge numbers of
    them... I can't download them all. I can simply use a <img> tag to
    get graphics on my web pages by pointing to their "http://[their
    webserver]/[image].gif", but that means that hackers and others can
    simply "decompose" my webpages and see that I'm just a downline
    supplier to a wholesale distributor. The "domain" of the graphics
    location will be different than my domain.

    So I wanna transport the graphic to the page by a webserver to
    webserver call from my domain. And, I need to be able to give the
    ServerXMLHTTP function a dynamic http:// string within the script...

    I've already tried server.execute, but I can't use a querystring with
    that... I've tried response.contenttype ... I need to be able to get
    the link to the graphic from the database then parse it into a string
    and dynamically make an http:// call out the their webserver and then
    binarywrite it back to the location on the page, intermingling the
    graphic stream with other returned html...

    I wish this would work.
     
    katrinaVictim@., Oct 17, 2005
    #4
  5. katrinaVictim@.

    McKirahan Guest

    <katrinaVictim@.> wrote in message
    news:...
    > On Sun, 16 Oct 2005 01:50:25 -0500, "McKirahan" <>
    > wrote:


    [snip]

    > You're correct. Response.body does return the graphic to the browser
    > if NO html surrounds the functional code.
    >
    > I had left in the <html><body>....</body></html> tags around the
    > VBScript above before I posted to the newsgroup (whoops), and when
    > doing this the browser then interprets the content as "text". Try
    > putting in a mere <html> tag before the code and you'll get a bunch of
    > extended ascii and stuff in the browser when using responseBody.
    >
    > See, here's my issue. I have graphics that are availabe on an
    > e-commerce drop ship suppliers web server. There are huge numbers of
    > them... I can't download them all. I can simply use a <img> tag to
    > get graphics on my web pages by pointing to their "http://[their
    > webserver]/[image].gif", but that means that hackers and others can
    > simply "decompose" my webpages and see that I'm just a downline
    > supplier to a wholesale distributor. The "domain" of the graphics
    > location will be different than my domain.
    >
    > So I wanna transport the graphic to the page by a webserver to
    > webserver call from my domain. And, I need to be able to give the
    > ServerXMLHTTP function a dynamic http:// string within the script...
    >
    > I've already tried server.execute, but I can't use a querystring with
    > that... I've tried response.contenttype ... I need to be able to get
    > the link to the graphic from the database then parse it into a string
    > and dynamically make an http:// call out the their webserver and then
    > binarywrite it back to the location on the page, intermingling the
    > graphic stream with other returned html...
    >
    > I wish this would work.
    >


    Take a look at this. Watch for word-wrap.

    Create a folder called "images" under the folder that this file is in.


    <%@ Language=VBScript %>
    <% Option Explicit

    Function Fetch(URL)
    On Error Resume Next
    Err.Clear
    '*
    '* Get Image
    '*
    Dim objXML
    'Set objXML = Server.CreateObject("Msxml2.ServerXMLHTTP")
    Set objXML = Server.CreateObject("Microsoft.XMLHTTP")
    objXML.Open "GET",URL,False
    objXML.Send
    Dim binXML
    binXML = objXML.ResponseBody
    If Err.Number <> 0 _
    Or objXML.Status <> 200 Then
    Fetch = False
    Exit Function
    End If
    Set objXML = Nothing
    '*
    '* Put Image
    '*
    Dim strIMG
    strIMG = "images\" & Mid(xURL,InStrRev(URL,"/")+1)
    Dim objADO
    Set objADO = CreateObject("ADODB.Stream")
    objADO.Type = 1
    objADO.Open
    objADO.Write binXML
    objADO.SaveToFile Server.MapPath(strIMG),2
    Set objADO = Nothing
    'Fetch = Err.Number = 0
    Fetch = strIMG
    End Function
    %>
    <html>
    <body>
    <img src="<%=Fetch("http://www.google.com/intl/en/images/logo.gif")%>"
    border="0" alt="">
    </body>
    </html>
     
    McKirahan, Oct 17, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Maris Janis Vasilevskis

    MSXML2.ServerXMLHTTP to HttpWebRequest: Error 500

    Maris Janis Vasilevskis, Aug 29, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    6,312
    Maris Janis Vasilevskis
    Aug 29, 2005
  2. bo0oost

    Msxml2.ServerXMLHTTP

    bo0oost, Apr 17, 2004, in forum: XML
    Replies:
    0
    Views:
    2,810
    bo0oost
    Apr 17, 2004
  3. MSXML2.ServerXMLHTTP

    , Aug 23, 2005, in forum: ASP .Net Web Services
    Replies:
    7
    Views:
    785
    dado49
    Aug 25, 2005
  4. Dick Berthold

    MSXML2.ServerXMLHTTP

    Dick Berthold, Jun 5, 2006, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    176
    Dick Berthold
    Jun 5, 2006
  5. NeedHelp

    Msxml2.ServerXMLHTTP and Time Out

    NeedHelp, Feb 11, 2010, in forum: ASP General
    Replies:
    9
    Views:
    3,951
    Evertjan.
    Feb 13, 2010
Loading...

Share This Page