POST request frow windows app??

B

Brad

I'm in the processing of upgrading some VBA code that sends a POST-AUTH
request to a secure server (credit card authorization to a payment
gateway) then parses the return. I'm trying to figure out how to do
this with VB 2005 Windows App.

Old Code example:
'Get ready to send request to gateway
WinHttpReq.Open("POST", "https://***URLTOSECURESERVER**", False)
WinHttpReq.SetRequestHeader("Content-Type",
"application/x-www-form-urlencoded")
WinHttpReq.Send(strPostString)
lStatusCode = WinHttpReq.Status
lsReturn = WinHttpReq.ResponseText

How to do the same thing in .net?
 
C

Carl Daniel [VC++ MVP]

Brad said:
I'm in the processing of upgrading some VBA code that sends a
POST-AUTH request to a secure server (credit card authorization to a
payment gateway) then parses the return. I'm trying to figure out
how to do this with VB 2005 Windows App.

Old Code example:
'Get ready to send request to gateway
WinHttpReq.Open("POST", "https://***URLTOSECURESERVER**", False)
WinHttpReq.SetRequestHeader("Content-Type",
"application/x-www-form-urlencoded")
WinHttpReq.Send(strPostString)
lStatusCode = WinHttpReq.Status
lsReturn = WinHttpReq.ResponseText

How to do the same thing in .net?

See the System.Net.HttpWebRequest class. The method names, properties, etc,
are nearly the same - you should have no trouble translating.

-cd
 
B

Brad

Ok, I got that to post. Now, my next problem is getting back all of
the server response. I can't seem to get all of the data from the
response. How can I get back the response and parse out the
information?

Old code:
lStatusCode = WinHttpReq.Status
lsReturn = WinHttpReq.ResponseText
'parse the return values
lasReturn = Split(lsReturn, "&")
For i = 0 To UBound(lasReturn)
lasKeyPair = Split(lasReturn(i), "=")
Select Case LCase(lasKeyPair(0))
Case "responsecode"
lsResponseCode = lasKeyPair(1)
Case "responsemessage"
lsResponseMessage = lasKeyPair(1)
Case "transactionid"
lsTransactionID = lasKeyPair(1)
Case "avsresponse"
lsAVSResponse = lasKeyPair(1)
Case "cvv2response"
lsCVV2Response = lasKeyPair(1)
Case "authcode"
lsAuthCode = lasKeyPair(1)
End Select
 
C

Carl Daniel [VC++ MVP]

Brad said:
Ok, I got that to post. Now, my next problem is getting back all of
the server response. I can't seem to get all of the data from the
response. How can I get back the response and parse out the
information?

What are you trying? Typically, you'll call
HttpWebResponse.GetResponseStream() and read the response line by line, or
all at once, however you wish.

-cd
 

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

Top