Trying to serialise object as XML to Memory Stream and then send in HttpWebRequest

S

student

I have an object created called objM_message.

I want to serialize it as xml and place the xml in my
HttpWebRequest.GetRequestStream.

But the line resp = req.GetResponse
doesnt return any results .. it should do

My question is this. Is the WriteTo() method the proper one to use to
pass the contents of my memory stream into the
req.GetRequestStream

Graham

-----------------------------------------------------------
Dim memStream As New MemoryStream
serializeAPP.Serialize(memStream, objM_message)
memStream.Position = 0

Dim req As HttpWebRequest = WebRequest.Create("myURL")
Dim resp As HttpWebResponse

req.Method = "POST"
req.ContentType = "application/x-www-form-urlencoded; charset=UTF-8"

req.ContentLength = memStream.Length
'=======================================================
' Attempt to write XML in my XML obj to Request Stream
'=======================================================
Try

memStream.WriteTo(req.GetRequestStream)
memStream.Flush()
memStream.Close()

Catch e1 As Exception
Console.Write("Error in request stream")
End Try
'=======================================================
' Send down the request and get the response back
'=======================================================
resp = req.GetResponse
 

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

Top