Web page code that works:
Imports System.IO
Imports System.Xml
Imports System.Xml.Sche ma
Imports System.Net.Cred entialCache
Imports System.Text
Imports System.net
Public Class Class1
Private Sub SendDoc(ByRef sData As String)
Const k_send_to_url As String
= "http://localhost/Reader/Receive.aspx"
Dim request_obj As HttpWebRequest
Dim request_stream As Stream
Dim response_obj As HttpWebResponse
Dim xml_reader As XmlTextReader
Dim docobj As New XmlDocument
Try
request_obj = CType(WebReques t.Create
(k_send_to_url) , HttpWebRequest)
request_obj.Met hod = "POST"
request_obj.Con tentType = "text/xml"
request_obj.Tim eout = 999999999
request_obj.All owWriteStreamBu ffering = True
request_stream = request_obj.Get RequestStream
()
docobj.LoadXml( sData)
docobj.Save(req uest_stream)
request_stream. Close()
docobj = Nothing
response_obj = request_obj.Get Response()
xml_reader = New XmlTextReader
(response_obj.G etResponseStrea m())
docobj = New XmlDocument
docobj.Load(xml _reader)
request_obj = Nothing
request_stream = Nothing
response_obj = Nothing
Catch ex As Exception
Exit Sub
End Try
End Sub
End Class
Windows code that doesn't:
Imports System.IO
Imports System.Xml
Imports System.Xml.Sche ma
Imports System.Net.Cred entialCache
Imports System.Text
Imports System.net
Public Class Class1
Private Sub SendDoc(ByRef sData As String)
Const k_send_to_url As String
= "http://localhost/Reader/Receive.aspx"
Dim request_obj As HttpWebRequest
Dim request_stream As Stream
Dim response_obj As HttpWebResponse
Dim xml_reader As XmlTextReader
Dim docobj As New XmlDocument
Try
request_obj = CType(WebReques t.Create
(k_send_to_url) , HttpWebRequest)
request_obj.Met hod = "POST"
request_obj.Con tentType = "text/xml"
request_obj.Tim eout = 999999999
request_obj.All owWriteStreamBu ffering = True
request_stream = request_obj.Get RequestStream
()
docobj.LoadXml( sData)
docobj.Save(req uest_stream)
request_stream. Close()
docobj = Nothing
response_obj = request_obj.Get Response()
xml_reader = New XmlTextReader
(response_obj.G etResponseStrea m())
docobj = New XmlDocument
docobj.Load(xml _reader)
request_obj = Nothing
request_stream = Nothing
response_obj = Nothing
Catch ex As Exception
Exit Sub
End Try
End Sub
End Class
-----Original Message-----
Brian Brown <bb****@hotmail .com> wrote: I have code which works as an asp.net page that posts
an xml file to web page and gets a response back.
When the the calls GetResponse() it goes into the page
it's posting to to and works fine. When it's been
ported to a winform it doesn't work on the GetResponse() call.
I think it probably needs credentials but not sure
what to use, tried a few ids w/o any luck.
The asp.net page as well as the winform are on the
same server for now but will later be on seperate servers.
Could you post a short but complete program which
demonstrates theproblem?
See http://www.pobox.com/~skeet/csharp/complete.html for
details ofwhat I mean by that.
--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
.