Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 09:55 AM
Robert Brown
Guest
 
Posts: n/a
Default Calling URL and getting data back in. Use ADODB.Stream????

Hi All,

I am creating an interface into a Payment Gateway. I need to access a
URL (which is a perl script) with paramters attached. I will then get
a response within 10 seconds with information I need to formulate into
my pretty asp page.

I didn't know where to start but I have read alot about adodb.stream.
I setout to write some code and this is what I have done:

Set objStm = Server.CreateObject("ADODB.Stream")
objStm.Type = adTypeText
objStm.Open "URL=" & theurl, admoderead, 8
objStm.Charset = "ascii"
strText = objStm.ReadText
Response.Write strText

theURL variable contains the URL with the payment parameters.

On the open line however, I get an error c004800a. What the hell this
means I don't know. It doesn't matter what I put into theURL even if
it is something like www.yahoo.com, I still get the same error....

Ok, I read an interesting post about using XMLHTTP. I created the code
as follows:

Dim xmlhttp
Set xmlhttp = Server.CreateObject("MSXML2.XMLHTTP")
xmlhttp.Open "GET", theURL, false
xmlhttp.Send
Response.write xmlhttp.responseText

This seems to work very well. I actually got an error back from the
payment gateway stating NO PARAMETERS SUPPLIED. Realising this, I used
a POST rather than GET. Doing this I got FAILED NEED LOGIN although
the Login information was passed as two of the parameters in the URL.
I am doing a response.write of theURL so i know that is is filled with
the correct information. I couldnt find out what the false was for, so
I changed that to true, and got this error: The data necessary to
complete this operation is not yet available.

I am so lost, is there anyone that might have ideas on how to get the
above working. If I just put the URL into the browser, if works OK, so
I know the syntax of theURL is fine.

Thanks for your time,
Robert
  #2  
Old July 19th, 2005, 09:55 AM
Aaron Bertrand - MVP
Guest
 
Posts: n/a
Default Re: Calling URL and getting data back in. Use ADODB.Stream????

If it's post, you should pass the information in post variables, not in the
URL. See http://www.aspfaq.com/2173 for some examples.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/




"Robert Brown" <rbrown@edium.com> wrote in message
news:bdd1819.0312030404.451c8b5e@posting.google.co m...[color=blue]
> Hi All,
>
> I am creating an interface into a Payment Gateway. I need to access a
> URL (which is a perl script) with paramters attached. I will then get
> a response within 10 seconds with information I need to formulate into
> my pretty asp page.
>
> I didn't know where to start but I have read alot about adodb.stream.
> I setout to write some code and this is what I have done:
>
> Set objStm = Server.CreateObject("ADODB.Stream")
> objStm.Type = adTypeText
> objStm.Open "URL=" & theurl, admoderead, 8
> objStm.Charset = "ascii"
> strText = objStm.ReadText
> Response.Write strText
>
> theURL variable contains the URL with the payment parameters.
>
> On the open line however, I get an error c004800a. What the hell this
> means I don't know. It doesn't matter what I put into theURL even if
> it is something like www.yahoo.com, I still get the same error....
>
> Ok, I read an interesting post about using XMLHTTP. I created the code
> as follows:
>
> Dim xmlhttp
> Set xmlhttp = Server.CreateObject("MSXML2.XMLHTTP")
> xmlhttp.Open "GET", theURL, false
> xmlhttp.Send
> Response.write xmlhttp.responseText
>
> This seems to work very well. I actually got an error back from the
> payment gateway stating NO PARAMETERS SUPPLIED. Realising this, I used
> a POST rather than GET. Doing this I got FAILED NEED LOGIN although
> the Login information was passed as two of the parameters in the URL.
> I am doing a response.write of theURL so i know that is is filled with
> the correct information. I couldnt find out what the false was for, so
> I changed that to true, and got this error: The data necessary to
> complete this operation is not yet available.
>
> I am so lost, is there anyone that might have ideas on how to get the
> above working. If I just put the URL into the browser, if works OK, so
> I know the syntax of theURL is fine.
>
> Thanks for your time,
> Robert[/color]


  #3  
Old July 19th, 2005, 09:55 AM
Jim C
Guest
 
Posts: n/a
Default Re: Calling URL and getting data back in. Use ADODB.Stream????

I am trying to do something very similar... I however get my page to
display, however, the refresh button does not work, it will just produce a
blank page.
Any body know why the refresh would not work?

My Code is the following:

<%@ Language=VBScript %>

<%
Option Explicit
%>

<%

Const adTypeBinary = 1
Const adReadAll = -1

Dim oStream
set oStream = server.CreateObject("ADODB.Stream")
oStream.Type = 2
oStream.Charset = "ascii"
oStream.Open "URL=http://testserver/test/hello.htm", 1, -1

'Response.write oStream.State
'Response.End
'oStream.Read

'Response.Write oStream.Size
'Response.End

oStream.Position = 0
Response.ContentType = "text/html"
Response.Write oStream.ReadText
Response.Buffer = True

oStream.close



"Robert Brown" <rbrown@edium.com> wrote in message
news:bdd1819.0312030404.451c8b5e@posting.google.co m...[color=blue]
> Hi All,
>
> I am creating an interface into a Payment Gateway. I need to access a
> URL (which is a perl script) with paramters attached. I will then get
> a response within 10 seconds with information I need to formulate into
> my pretty asp page.
>
> I didn't know where to start but I have read alot about adodb.stream.
> I setout to write some code and this is what I have done:
>
> Set objStm = Server.CreateObject("ADODB.Stream")
> objStm.Type = adTypeText
> objStm.Open "URL=" & theurl, admoderead, 8
> objStm.Charset = "ascii"
> strText = objStm.ReadText
> Response.Write strText
>
> theURL variable contains the URL with the payment parameters.
>
> On the open line however, I get an error c004800a. What the hell this
> means I don't know. It doesn't matter what I put into theURL even if
> it is something like www.yahoo.com, I still get the same error....
>
> Ok, I read an interesting post about using XMLHTTP. I created the code
> as follows:
>
> Dim xmlhttp
> Set xmlhttp = Server.CreateObject("MSXML2.XMLHTTP")
> xmlhttp.Open "GET", theURL, false
> xmlhttp.Send
> Response.write xmlhttp.responseText
>
> This seems to work very well. I actually got an error back from the
> payment gateway stating NO PARAMETERS SUPPLIED. Realising this, I used
> a POST rather than GET. Doing this I got FAILED NEED LOGIN although
> the Login information was passed as two of the parameters in the URL.
> I am doing a response.write of theURL so i know that is is filled with
> the correct information. I couldnt find out what the false was for, so
> I changed that to true, and got this error: The data necessary to
> complete this operation is not yet available.
>
> I am so lost, is there anyone that might have ideas on how to get the
> above working. If I just put the URL into the browser, if works OK, so
> I know the syntax of theURL is fine.
>
> Thanks for your time,
> Robert[/color]


  #4  
Old July 19th, 2005, 09:55 AM
Aaron Bertrand - MVP
Guest
 
Posts: n/a
Default Re: Calling URL and getting data back in. Use ADODB.Stream????

I have no experience using ADODB.Stream to read remote pages, but I use
XMLHTTP in many scenarios almost daily and rarely come across any issues.
See http://www.aspfaq.com/2173

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/




"Jim C" <clearstead@hotmail.com> wrote in message
news:u4Y3nabuDHA.2304@tk2msftngp13.phx.gbl...[color=blue]
> I am trying to do something very similar... I however get my page to
> display, however, the refresh button does not work, it will just produce a
> blank page.
> Any body know why the refresh would not work?
>
> My Code is the following:
>
> <%@ Language=VBScript %>
>
> <%
> Option Explicit
> %>
>
> <%
>
> Const adTypeBinary = 1
> Const adReadAll = -1
>
> Dim oStream
> set oStream = server.CreateObject("ADODB.Stream")
> oStream.Type = 2
> oStream.Charset = "ascii"
> oStream.Open "URL=http://testserver/test/hello.htm", 1, -1
>
> 'Response.write oStream.State
> 'Response.End
> 'oStream.Read
>
> 'Response.Write oStream.Size
> 'Response.End
>
> oStream.Position = 0
> Response.ContentType = "text/html"
> Response.Write oStream.ReadText
> Response.Buffer = True
>
> oStream.close
>[/color]


  #5  
Old July 19th, 2005, 09:56 AM
Robert Brown
Guest
 
Posts: n/a
Default Re: Calling URL and getting data back in. Use ADODB.Stream????

Hi Jim..

That I can help you. When the page is loaded through the stream, it is
only "text" representation of the page. Have a look at the source you
are getting back. That's why the Refresh button can't refresh anything.

Hope this helps,
Robert

PS: Least you get something... hee hee



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #6  
Old July 19th, 2005, 09:56 AM
Robert Brown
Guest
 
Posts: n/a
Default Re: Calling URL and getting data back in. Use ADODB.Stream????

Thanks for your reply... I knew someone would have a lead for me.

I put the code in as the example, except I am getting this error:

The system cannot locate the resource specified.

when I issue the xmlhttp.send "x=1&y=2" (made up params).

I don't want to impose too much, but would you have some time to help me
out again..

Thanks,
Robert



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #7  
Old July 19th, 2005, 09:56 AM
Aaron Bertrand - MVP
Guest
 
Posts: n/a
Default Re: Calling URL and getting data back in. Use ADODB.Stream????

Can you show all of the code, including the URL you are trying to hit. That
way someone can try to reproduce, instead of guessing what's going on. :-)

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/




"Robert Brown" <robear@joshie.com.au> wrote in message
news:eLE5YbfuDHA.1872@TK2MSFTNGP09.phx.gbl...[color=blue]
> Thanks for your reply... I knew someone would have a lead for me.
>
> I put the code in as the example, except I am getting this error:
>
> The system cannot locate the resource specified.
>
> when I issue the xmlhttp.send "x=1&y=2" (made up params).
>
> I don't want to impose too much, but would you have some time to help me
> out again..
>
> Thanks,
> Robert
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it![/color]


  #8  
Old July 19th, 2005, 09:56 AM
Robert Brown
Guest
 
Posts: n/a
Default Re: Calling URL and getting data back in. Use ADODB.Stream????

Yep.. Sure.. That was going to be my next step.

I will have too put bogus params in though as this contains credit card
stuff... but here goes:

theMainURL =
"https://4tknox.au.com/cgi-bin/themerchant.au.com/ecom/external2.pl"

theParams = "LOGIN=xxx/xxxx&COMMAND=purchase&AMOUNT=" & CreditAmount&
"&CCNUM=" & CreditCard & "&CCEXP=" & CreditExpiry & "&COMMENT=" &
CreditComment

Dim xmlhttp
'Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP") if I use this
line above I get the following error on the send: msxml3.dll error
'80072f8f' System error: -2147012721

Set xmlhttp = Server.CreateObject("MSXML2.XMLHTTP")
xmlhttp.Open "POST", theMainURL, false
xmlhttp.setRequestHeader "Content-Type",
"application/x-www-form-urlencoded"
xmlhttp.send theParams

Response.write xmlhttp.responseText


That's it.. I hope you can make some sense of it.

Thanks,
Robert

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles