Web Request

C

Carl Howarth

Hi,

I am trying to write a class to interface with a payment gateway (via an XML
string). I have managed to get this to work using the VB6 version of code,
but would rather like to use the .net webrequest/response techniques.

The VB6 style code I am using that works is as follows:

Dim xbroker As New MSXML2.ServerXMLHTTP

xbroker.open("POST", "http://127.0.0.1:5001/", False)
xbroker.send(stXML)
MsgBox(xbroker.responseText)

.............

The VB.NET code that is currently coming back with "(100) Timeout reading
from socket" is as follows:

Dim req As WebRequest
Dim rsp As WebResponse
Dim stResult As String

req = WebRequest.Create("http://127.0.0.1:5001/")
req.Method = "POST"
req.ContentType = "text/xml"

rsp = req.GetResponse

reader = New StreamReader(rsp.GetResponseStream)

MsgBox(reader.ReadToEnd)

reader = Nothing

If Not rsp Is Nothing Then rsp.GetResponseStream.Close()
..............................

Any ideas please?

Thanks in anticipation,

Carl
 
J

Joerg Jooss

Carl said:
Hi,

I am trying to write a class to interface with a payment gateway (via
an XML string). I have managed to get this to work using the VB6
version of code, but would rather like to use the .net
webrequest/response techniques.

The VB6 style code I am using that works is as follows:

Dim xbroker As New MSXML2.ServerXMLHTTP

xbroker.open("POST", "http://127.0.0.1:5001/", False)
xbroker.send(stXML)
MsgBox(xbroker.responseText)

............

The VB.NET code that is currently coming back with "(100) Timeout
reading from socket" is as follows:

Dim req As WebRequest
Dim rsp As WebResponse
Dim stResult As String

req = WebRequest.Create("http://127.0.0.1:5001/")
req.Method = "POST"
req.ContentType = "text/xml"

rsp = req.GetResponse

reader = New StreamReader(rsp.GetResponseStream)

MsgBox(reader.ReadToEnd)

reader = Nothing

If Not rsp Is Nothing Then rsp.GetResponseStream.Close()
.............................

Any ideas please?

You don't send anything. The web server waits forever to get the HTTP
request's body, but there's none. You must write your payload (e.g. XML
string) to the request stream.

Cheers,
 

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
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top