I know how to POST regular data, but not sure how to POST an XML file to a public web service that requires it. Using Asp.net. Are there several ways? Choose best practice.
A:
They will probably have a form variable that you will put your whole XML string into. For example if they had a form variable named xmlData, you would set that value in your post to equal your whole xml file and then post it.
Jeff Pegg
2009-11-30 19:24:08
+1
A:
If it's not a SOAP Web Service then something like this should work...
string xml = "<xmldoc />"; //your XML
string webservice = "http://mywebservice.com";
System.Net.WebRequest webreq = System.Net.WebRequest.Create(webservice);
webreq.Method = "POST";
webreq.ContentType = "text/xml";
System.IO.StreamWriter writer = new System.IO.StreamWriter(webreq.GetRequestStream());
writer.WriteLine(xml);
writer.Close();
System.Net.WebResponse webrsp = webreq.GetResponse();
string result = webrsp.ToString();
CptSkippy
2009-11-30 20:00:27