![]() |
msxml2.serverXMLhttp and response.binarywrite
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. |
Re: msxml2.serverXMLhttp and response.binarywrite
<katrinaVictim@.> wrote in message news:tod3l1hvbcu830dauqb3t5tfadbmgjs03m@4ax.com... > 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 |
Re: msxml2.serverXMLhttp and response.binarywrite
<katrinaVictim@.> wrote in message
news:tod3l1hvbcu830dauqb3t5tfadbmgjs03m@4ax.com... : 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 |
Re: msxml2.serverXMLhttp and response.binarywrite
On Sun, 16 Oct 2005 01:50:25 -0500, "McKirahan" <News@McKirahan.com>
wrote: ><katrinaVictim@.> wrote in message >news:tod3l1hvbcu830dauqb3t5tfadbmgjs03m@4ax.com.. . >> 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/langua...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. |
Re: msxml2.serverXMLhttp and response.binarywrite
<katrinaVictim@.> wrote in message
news:lli6l11ibkm4fiol2ur351mr070rfjccso@4ax.com... > On Sun, 16 Oct 2005 01:50:25 -0500, "McKirahan" <News@McKirahan.com> > 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> |
| All times are GMT. The time now is 01:34 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.