Eugene,
I wrapped up the HTTP functions in a separate class.
I hope this helps.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Imports System.Net
Imports System.IO
Imports System.Text
Public Class MasterPost
#Region "Public Functions"
Public Shared Function PostMessage(ByVal Message As String, ByVal URL As
String) As XmlNode
Try
'~~~ Set the data to send
Dim postData As String = Message
Dim encoding As New ASCIIEncoding
Dim byte1 As Byte() = encoding.GetBytes(postData)
Dim request As HttpWebRequest = CType(WebRequest.Create(URL),
HttpWebRequest)
'~~~ Set the Request properties and send the data.
request.ContentType = "text/xml"
request.ContentLength = postData.Length
request.Method = "POST"
Dim newStream As Stream = request.GetRequestStream()
newStream.Write(byte1, 0, byte1.Length)
newStream.Close()
'~~~ Get the response.
Dim response As HttpWebResponse = CType(request.GetResponse(),
HttpWebResponse)
Dim recvStream As Stream = response.GetResponseStream()
Dim readStream As New StreamReader(recvStream, encoding.UTF8)
Dim objXml As New XmlDocument
Dim objBody As XmlNode
Dim objRoot As XmlElement
objXml.XmlResolver = Nothing
objXml.LoadXml(strXml)
objRoot = objXml.DocumentElement
objBody = objRoot.SelectSingleNode("//AvailableResponse")
Debug.WriteLine(objBody.OuterXml)
Return objBody
objBody = Nothing
objXml = Nothing
response.Close()
readStream.Close()
Catch ex As Exception
Return Nothing
Throw ex
End Try
End Function
#End Region
End Class
"Eugene Kosnyrev" wrote:
Could you please provide a sample code how you use HttpWebRequest object
instead of MSXML2.ServerXMLHTTP40?
Thanks, Eugene.
*** Sent via Developersdex http://www.developersdex.com ***