XML Posting to Web Service Problems

M

michael.esposito

I am having issues with this code. It posts the XML file to the web
service without a problem, but when I go to get the response, it times
out. Even when the timeout was set to infinite, it ran all night
without any response. Anyone know what might be wrong?

Thanks,
Michael

Dim strURL As String = "http://webservice:8080/"

'Set path of xml file to pass via HTTP
Dim xmlPath As String = "C:\Test\map_test.xml"

'Send XML document to receving page and print result

' open the document...
Dim clsDocument As New System.Xml.XmlDocument
clsDocument.Load(xmlPath)

' create a request class...
Dim clsRequest As System.Net.WebRequest =
System.Net.HttpWebRequest.Create(strURL)
clsRequest.Timeout = System.Threading.Timeout.Infinite
clsRequest.Credentials = New
System.Net.NetworkCredential("username", "password")
clsRequest.Method = "POST"

' get request stream and write document to it...
Dim clsStream As System.IO.Stream =
clsRequest.GetRequestStream() 'TIMEOUT
clsDocument.Save(clsStream)

' close the stream...
clsStream.Flush()
'clsStream.Dispose()
clsStream = Nothing
 
J

Joerg Jooss

Thus wrote (e-mail address removed),
I am having issues with this code. It posts the XML file to the web
service without a problem, but when I go to get the response, it times
out. Even when the timeout was set to infinite, it ran all night
without any response. Anyone know what might be wrong?

Thanks,
Michael
Dim strURL As String = "http://webservice:8080/"

'Set path of xml file to pass via HTTP
Dim xmlPath As String = "C:\Test\map_test.xml"
'Send XML document to receving page and print result

' open the document...
Dim clsDocument As New System.Xml.XmlDocument
clsDocument.Load(xmlPath)
' create a request class...
Dim clsRequest As System.Net.WebRequest =
System.Net.HttpWebRequest.Create(strURL)
clsRequest.Timeout = System.Threading.Timeout.Infinite
clsRequest.Credentials = New
System.Net.NetworkCredential("username", "password")
clsRequest.Method = "POST"
' get request stream and write document to it...
Dim clsStream As System.IO.Stream =
clsRequest.GetRequestStream() 'TIMEOUT
clsDocument.Save(clsStream)
' close the stream...
clsStream.Flush()
'clsStream.Dispose()
clsStream = Nothing

Why did you remove the call to Dispose()? You must close 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

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top