Protected void btnSubmit_Click (object sender, EventArgs e)
{
String strReqXML = "<? Xml version = \ "1.0 \" encoding = \ "UTF-8 \"?> <Soap: Envelope xmlns: xsi = \ "Courier" xmlns: xsd = \ "http://www.w3.org/2001/XMLSchema\" xmlns: soap = \ "Courier"> <soap: body> <getWeatherbyCityName xmlns = \ "http://WebXml.com.cn/\"> <theCityName> "+ txtCity. text + "</theCityName> </getWeatherbyCityName> </soap: Body> </soap: Envelope>"; // getWeatherbyCityName method, theCityName parameter name
Byte [] buff = System. Text. Encoding. UTF8.GetBytes (strReqXML );
HttpWebRequest hwr = (HttpWebRequest) HttpWebRequest. Create ("http://www.webxml.com.cn/WebServices/WeatherWebService.asmx ");
Hwr. ContentType = "text/xml; charsets = UTF-8 ";
Hwr. ContentLength = buff. Length;
Hwr. Method = "POST ";
Stream sr = hwr. GetRequestStream ();
Sr. Write (buff, 0, buff. Length );
WebResponse wr = hwr. GetResponse ();
DataSet ds = new DataSet ();
Ds. ReadXml (wr. GetResponseStream ());
TxtResult. Text = ds. Tables [3]. Rows [1] [0]. ToString (); // you can obtain information in the returned dataset.
Wr. Close ();
Sr. Close ();
}