using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Text; using System.Net; using System.IO; public partial class Default2 : System.Web.UI.Page { HttpWebRequest webRequest = null; protected void Page_Load(object sender, EventArgs e) { string RequestXML = "" + "admin" + "admin"; string ServerURL = "http://localhost:8080/geonetwork/srv/en/xml.user.login"; string ResponseXML = postRequest(RequestXML, ServerURL); Textbox1.Text = ResponseXML.ToString(); string ServerURL1 = "http://localhost:8080/geonetwork/srv/en/xml.metadata.get"; string RequestXML1 = "" + "5915639e-777c-4339-93ad-c4037f2eeb77" + ""; string ResponseXML1 = postRequest(RequestXML1, ServerURL1); } private string postRequest(String RequestXML, string ServerURL) { int timeout = 90000; int connectionLimit = 10; string responseXML = string.Empty; try { 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; }