Submitting XML to an URL

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.
 
J

Joerg Jooss

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,
 

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