protected void Page_Load(object sender, EventArgs e) { // load that XML that you want to post // it doesn't have to load from an XML doc, this is just // how we do it XmlDocument doc = new XmlDocument(); doc.Load( Server.MapPath( "XMLFile2.xml" ) ); // create the request to your URL HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost:2092/newlocaidstuff/Default4.aspx"); // add the headers // the SOAPACtion determines what action the web service should use // YOU MUST KNOW THIS and SET IT HERE //request.Headers.Add( "SOAPAction", YOUR SOAP ACTION ); // set the request type // we user utf-8 but set the content type here request.ContentType = "text/xml;charset=\"utf-8\""; request.Accept = "text/xml"; request.Method = "POST"; // add our body to the request System.IO.Stream stream = request.GetRequestStream(); doc.Save( stream ); stream.Close(); // get the response back using( HttpWebResponse response = (HttpWebResponse)request.GetResponse() ) { System.IO.StreamReader rd = new System.IO.StreamReader(response.GetResponseStream()); // do something with the response here Response.Write(rd); }//end using }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)