davoman
asked on
Using HTTP Post with XML
Hi there
I am uploading some data in XML format and they NEED it in an HTTP Form post but not sure how to do that. Can anyone point me in the right direction
I am uploading some data in XML format and they NEED it in an HTTP Form post but not sure how to do that. Can anyone point me in the right direction
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
sorry took so long but had a problem with it not acctually posing any data doing the above
What exactly is your code and how do you know it is not posting anything? As they say: "it works on my machine". Do you capture the network traffic? Or put another way, can you tell if the problem is that the data is not posted or that you are just not reading it properly in the server code?
ASKER
managed to adapte some other code but used this elsewhere cheers
WebRequest rq = WebRequest.Create("<server
rq.Method = "POST";
// If your XML data is not in a string, you just need to get its length,
// set the ContentLength, and write the data to the RequestStream.
string rqData = <your XML data>;
rq.ContentLength = rqData.Length;
Stream s = rq.GetRequestStream();
StreamWriter sw = new StreamWriter(s);
sw.Write(rqData);
sw.Close();
WebResponse wr = rq.GetResponse();
// Handle response...
You may also need to set some other headers like ContentType, etc. Talk to the server implementers about what headers are required/expected.