private string GetLoginServerVersion(string loginServerURI)
{
string version="";
// getting HEAD only does not (currently) work because OpenSim LoginServer only supports GET method
/*
HttpWebRequest req = WebRequest.Create(loginServerURI) as HttpWebRequest;
req.Method = "HEAD";
response = req.GetResponse() as HttpWebResponse;
headers = response.Headers;
foreach (string headerKey in headers.AllKeys)
{
if (headerKey.ToLower() == "x-gridservices")
{
string[] values;
values = headers.GetValues(headerKey);
string gridUri = values[0];
Console.WriteLine(gridUri);
}
}
*/
// try to fetch document from login server (with GET), then extract headers
System.Net.WebClient wc = new System.Net.WebClient();
string service_provider_url = "";
wc.DownloadData(loginServerURI); // Just want the header
if (wc.ResponseHeaders != null)
{
service_provider_url = wc.ResponseHeaders.Get("x-gridservices");
if (String.IsNullOrEmpty(service_provider_url))
{
throw new Exception("can not find service_provider url");
}
// get XML from grid services URL
XmlReader reader = XmlReader.Create(service_provider_url);
XPathDocument xpathDoc = new XPathDocument(reader);
XPathNavigator xpathnav = xpathDoc.CreateNavigator();
//string xpathQuery = "/GridServices/Service[attribute::type='LoginService']/version";
string xpathQuery = "/GridServices/Service[type='LoginService']/version";
XPathExpression xpathExpr = xpathnav.Compile(xpathQuery);
XPathNodeIterator xpathIter = xpathnav.Select(xpathExpr);
if (xpathIter.MoveNext())
{
version = xpathIter.Current.Value;
}
}
return version;
}