private string GetBaseURL(VixServiceTypes serviceType) { Log.Debug("Retrieving base URLs for " + serviceType.ToString() + " service..."); string ServiceType; string BaseUrl = string.Empty; // change facace based on type switch (serviceType) { case VixServiceTypes.Pathology: ServiceType = "Pathology"; break; case VixServiceTypes.Patient: ServiceType = "Patient"; break; case VixServiceTypes.User: ServiceType = "User"; break; default: ServiceType = "Pathology"; break; } string IDSUrl = string.Format(SecureIDSQueryFormatString, this.VixServerName, this.VixServerPort, ServiceType); // getting the application path HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(IDSUrl); webRequest.Credentials = new NetworkCredential(VixUserName, VixPassword); HttpWebResponse response; try { response = (HttpWebResponse)webRequest.GetResponse(); } catch (Exception ex) { Log.Error("IDS: " + IDSUrl, ex); throw new MagVixFailureException("Cannot request IDS URL", ex); } // getting the application and operation path string VixApplicationPath = string.Empty; string VixOperationPath = string.Empty; using (Stream webStream = response.GetResponseStream()) using (XmlTextReader xmlReader = new XmlTextReader(webStream)) using (StreamReader webReader = new StreamReader(webStream)) { XmlDocument xmlDoc = new XmlDocument(); try { xmlDoc.Load(xmlReader); string nodeAppPath = string.Format(VixApplicationPathQueryString, ServiceType); string nodeOperationPath = string.Format(VixMetadataOperationPathQueryString, ServiceType); VixApplicationPath = xmlDoc.SelectSingleNode(nodeAppPath).InnerText; VixOperationPath = xmlDoc.SelectSingleNode(nodeOperationPath).InnerText; } catch (Exception ex) { Log.Error("Failed to get app/op path.", ex); throw new MagVixFailureException("Failed to retrieve application and operation path", ex); } } // get the base url BaseUrl = string.Format(SecureBaseUrlFormatString, this.VixServerName, this.VixServerPort, VixApplicationPath, VixOperationPath); return BaseUrl; }