Hi
i used the following code to get the response i got the response for login service but cannot get the response from the url (http://localhost:8080/geonetwork/srv/en/xml.metadata.get) and i ended up getting the error 403 forbidden
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;
}
here is the code i used pl correct me where i went worng