Submitting XML to an URL

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
I'm not sure this is the right place for this question, but hopefully
somebody can help.
I'm trying to build an in-memory XML file and submit it to an URL. Here's a
sample code:

//====================================================
HttpWebRequest request =
(HttpWebRequest)WebRequest.Create("http://localhost/localurl.aspx");
request.ContentType="application/x-www-form-urlencoded";
request.Method = "POST";

Stream myStream = request.GetRequestStream();
XmlTextWriter writer = new XmlTextWriter(myStream, null);

writer.WriteStartElement("orders");
writer.WriteAttributeString("value","205");
writer.WriteEndElement();

writer.Flush();
myStream.Close();
//====================================================

For some reason, the URL I'm submitting to does not receive the XML.
Anybody has any ideas why?

Thnks in advance.
 
Vi said:
Hello,
I'm not sure this is the right place for this question, but hopefully
somebody can help.
I'm trying to build an in-memory XML file and submit it to an URL.
Here's a sample code:

//====================================================
HttpWebRequest request =
(HttpWebRequest)WebRequest.Create("http://localhost/localurl.aspx");
request.ContentType="application/x-www-form-urlencoded";
request.Method = "POST";

Stream myStream = request.GetRequestStream();
XmlTextWriter writer = new XmlTextWriter(myStream, null);

writer.WriteStartElement("orders");
writer.WriteAttributeString("value","205");
writer.WriteEndElement();

writer.Flush();
myStream.Close();
//====================================================

For some reason, the URL I'm submitting to does not receive the XML.
Anybody has any ideas why?

The Content-Type is wrong -- it should be text/xml instead. But this
should not prevent data from being received.

Try to use a debugging proxy like Fiddler (www.fiddlertool.com) to find
out what's going on "on the wire".

Cheers,
 
Back
Top