public static void configProxy() { var proxyClient = new oppslagstjeneste1602Client("oppslagstjeneste_ver2_v6"); proxyClient.Endpoint.Binding.CloseTimeout = proxyClient.Endpoint.Binding.OpenTimeout = proxyClient.Endpoint.Binding.ReceiveTimeout = proxyClient.Endpoint.Binding.SendTimeout = TimeSpan.FromMinutes(1); proxyClient.ChannelFactory.Endpoint.Behaviors.Add(new InspectorBehavior()); try { var hentPersonRequest = HentPersonerRequest(); var response = proxyClient.HentPersoner(hentPersonRequest); } catch (Exception exception) { if (exception.InnerException == null) { Trace.WriteLine(exception.Message); } else { Trace.WriteLine(exception.InnerException); } } }
public static oppslagstjeneste1602Client GetClient() { ServicePointManager.ServerCertificateValidationCallback += EasyCertCheck; var dnsIdentity = EndpointIdentity.CreateDnsIdentity("DIREKTORATET FOR FORVALTNING OG IKT"); var address = new EndpointAddress(new Uri("https://kontaktinfo-ws-ver2.difi.no/kontaktinfo-external/ws-v5"), dnsIdentity); var myCustomBinding = CreateCustomBinding(); var client = new oppslagstjeneste1602Client(myCustomBinding, address); client.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindByThumbprint, "8702F5E55217EC88CF2CCBADAC290BB4312594AC"); client.ClientCredentials.ServiceCertificate.SetDefaultCertificate(StoreLocation.CurrentUser, StoreName.TrustedPeople, X509FindType.FindByThumbprint, "a4 7d 57 ea f6 9b 62 77 10 fa 0d 06 ec 77 50 0b af 71 c4 32"); var protectionlevel = client.ChannelFactory.Endpoint.Contract.ProtectionLevel; client.ChannelFactory.Endpoint.Contract.ProtectionLevel = ProtectionLevel.Sign; return(client); }