private WSRegistryServicePortTypeClient GetClient(String username, String password, String serverURL, Binding binding) { ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback( delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors policyErrors) { return(true); }); AuthenticationAdminPortTypeClient authenticationAdmin = new AuthenticationAdminPortTypeClient(binding, new EndpointAddress(serverURL + "AuthenticationAdmin")); using (new OperationContextScope(authenticationAdmin.InnerChannel)) { if (!authenticationAdmin.login(username, password, "127.0.0.1")) { throw new SecurityException("Failed to login to system."); } HttpResponseMessageProperty response = (HttpResponseMessageProperty) System.ServiceModel.OperationContext.Current. IncomingMessageProperties[HttpResponseMessageProperty.Name]; cookie = response.Headers[HttpResponseHeader.SetCookie]; } return(new WSRegistryServicePortTypeClient(binding, new EndpointAddress(serverURL + "WSRegistryService"))); }
private WSRegistryServicePortTypeClient GetClient(String username, String password, String serverURL, Binding binding) { ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback( delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors policyErrors) { return true; }); AuthenticationAdminPortTypeClient authenticationAdmin = new AuthenticationAdminPortTypeClient(binding, new EndpointAddress(serverURL + "AuthenticationAdmin")); using (new OperationContextScope(authenticationAdmin.InnerChannel)) { if (!authenticationAdmin.login(username, password, "127.0.0.1")) { throw new SecurityException("Failed to login to system."); } HttpResponseMessageProperty response = (HttpResponseMessageProperty) System.ServiceModel.OperationContext.Current. IncomingMessageProperties[HttpResponseMessageProperty.Name]; cookie = response.Headers[HttpResponseHeader.SetCookie]; } return new WSRegistryServicePortTypeClient(binding, new EndpointAddress(serverURL + "WSRegistryService")); }