The
sends data as XML data, for example:
public void postxml (string url, string xml)
{
byte[] bytes = Encoding.UTF8.GetBytes (XML);
HttpWebRequest request = (HttpWebRequest) webrequest.create (URL);
Request. Method = "POST";
Request. contentlength = bytes. Length;
Request. ContentType = "Text/xml";
Using Stream requeststream = Request. GetRequestStream ()) {
requestStream.Write (bytes, 0, bytes. Length);
}httpwebresponse response = (HttpWebResponse) request. GetResponse ();
if (response. StatusCode! = Httpstatuscode.ok) {
String message = String.Format ("POST failed. Received HTTP {0} ",
Response. StatusCode);
Throw new ApplicationException (message);
}
}
receive end read via Request.inputstream:
byte[] Byts = new Byte[request.inputstream.length];
Request.InputStream.Read (Byts,0,byts. Length);
String req = System.Text.Encoding.Default.GetString (Byts);
Req = Server.urldecode (req);
For complete XML data, you can:
xmldoc = new XmlDocument ();
Xmldoc.load (Request.inputstream);
ASP. NET uses Request.inputstream to send data as XML data to receive