Web page code that works:
Imports System.IO
Imports System.Xml
Imports System.Xml.Schema
Imports System.Net.CredentialCache
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(WebRequest.Create
(k_send_to_url), HttpWebRequest)
request_obj.Method = "POST"
request_obj.ContentType = "text/xml"
request_obj.Timeout = 999999999
request_obj.AllowWriteStreamBuffering = True
request_stream = request_obj.GetRequestStream
()
docobj.LoadXml(sData)
docobj.Save(request_stream)
request_stream.Close()
docobj = Nothing
response_obj = request_obj.GetResponse()
xml_reader = New XmlTextReader
(response_obj.GetResponseStream())
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.Schema
Imports System.Net.CredentialCache
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(WebRequest.Create
(k_send_to_url), HttpWebRequest)
request_obj.Method = "POST"
request_obj.ContentType = "text/xml"
request_obj.Timeout = 999999999
request_obj.AllowWriteStreamBuffering = True
request_stream = request_obj.GetRequestStream
()
docobj.LoadXml(sData)
docobj.Save(request_stream)
request_stream.Close()
docobj = Nothing
response_obj = request_obj.GetResponse()
xml_reader = New XmlTextReader
(response_obj.GetResponseStream())
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.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
.