msxml2.serverXMLhttp and response.binarywrite

katrinaVictim

Usenet Archive
Joined
Oct 15, 2005
Messages
5
Reaction score
0
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.
 

McKirahan

Usenet Archive
Joined
Dec 24, 2002
Messages
1,766
Reaction score
0
<katrinaVictim@.> wrote:

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 ...

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
 

Mark J. McGinty

Usenet Archive
Joined
Jun 22, 2001
Messages
148
Reaction score
0
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
 

Roland Hall

Usenet Archive
Joined
Nov 4, 2003
Messages
964
Reaction score
0
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 ...

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.
 

katrinaVictim

Usenet Archive
Joined
Oct 15, 2005
Messages
5
Reaction score
0
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.
 

McKirahan

Usenet Archive
Joined
Dec 24, 2002
Messages
1,766
Reaction score
0
[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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,051
Messages
3,104,251
Members
248,135
Latest member
tobystanx

Latest Threads

Top