|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
POST request frow windows app??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? Brad wrote:
Show quote > I'm in the processing of upgrading some VBA code that sends a See the System.Net.HttpWebRequest class. The method names, properties, etc, > 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? are nearly the same - you should have no trouble translating. -cd 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 Carl Daniel [VC++ MVP] wrote: Show quote > Brad wrote: > > 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 Brad wrote:
> Ok, I got that to post. Now, my next problem is getting back all of What are you trying? Typically, you'll call > 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? HttpWebResponse.GetResponseStream() and read the response line by line, or all at once, however you wish. -cd |
|||||||||||||||||||||||