protected void Page_Load(object sender, EventArgs e) { string RequestXML = "<request>" + "<username>admin</username>" + "<password>admin</password></request>"; string ServerURL = "http://localhost:8080/geonetwork/srv/en/xml.user.login"; string ResponseXML = postRequest(RequestXML, ServerURL); //= ResponseXML.ToString(); string ServerURL1 = "http://localhost:8080/geonetwork/srv/en/xml.metadata.get"; string RequestXML1 = "<request>" + "<uuid>5915639e-777c-4339-93ad-c4037f2eeb77</uuid>" + "</request>"; string ResponseXML1 = postRequest(RequestXML1, ServerURL1); Label1.Text = ResponseXML1.ToString(); } private string postRequest(String RequestXML, string ServerURL) { int timeout = 90000; int connectionLimit = 10; string responseXML = string.Empty; try { HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(ServerURL); webRequest.Timeout = timeout; webRequest.KeepAlive = true; webRequest.ServicePoint.ConnectionLimit = connectionLimit; webRequest.Method = "POST"; webRequest.ContentType = "text/xml"; byte[] byteArray = Encoding.UTF8.GetBytes(RequestXML); Stream strm = webRequest.GetRequestStream(); strm.Write(byteArray, 0, byteArray.Length); strm.Close(); HttpWebResponse webResponse =(HttpWebResponse)webRequest.GetResponse(); Encoding enc = Encoding.GetEncoding("utf-8"); StreamReader reader = new StreamReader(webResponse.GetResponseStream(), enc); responseXML = reader.ReadToEnd(); reader.Close(); webResponse.Close(); } catch (Exception ex) { throw (ex); } return responseXML; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)