receive a XML with POST method

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hello,
Im sending a XML with POST and the server get it and send a XML back with an message, but i only receive a bad request. But when i use fiddler i can see the XML response, but i cant get that with my c# code.
my code is
HttpWebResponse webResponse;<br/>
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http.....");<br/>
myRequest.Method = "POST";<br/>
myRequest.ContentType = "text/xml";<br/>
myRequest.Proxy = null;<br/>
string postData = @"<?xml version=1.0 encoding=UTF-8?> MY XML";<br/>
byte[] byteArray = Encoding.UTF8.GetBytes(postData);<br/>
myRequest.ContentLength = byteArray.Length;<br/>
<br/>
Stream readStream = myRequest.GetRequestStream();<br/>
<br/>
readStream.Write(byteArray, 0, byteArray.Length);<br/>
<br/>
webResponse = (HttpWebResponse)myRequest.GetResponse();<br/>
StreamReader reader = new StreamReader(webResponse.GetResponseStream());<br/>
MessageBox.Show(reader.ToString());<br/>
readStream.Close();
Thanks for any help

View the full article
 
Back
Top