using System; using System.Collections.Generic; using System.Linq; using System.Web; using HLWebOKBQueryPlugin.OKBQueryService; using System.ServiceModel.Security; namespace HLWebOKBQueryPlugin.Helpers { public class Query { public static QueryServiceClient GetClientFactory() { return GetClientFactory(GetSessionString("Username"), GetSessionString("Password")); } public static QueryServiceClient GetClientFactory(string username, string password) { try { QueryServiceClient client = new QueryServiceClient(); client.ClientCredentials.UserName.UserName = "okbtester"; client.ClientCredentials.UserName.Password = "okbtester"; client.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None; client.GetFilters(); return client; } catch { } return null; } public static string GetSessionString(string name) { if (name != null) { object o = HttpContext.Current.Session[name]; if (o != null) { return o.ToString(); } } return string.Empty; } } }