public HentPersonerResponse Execute(string[] personalNumber) { Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); EndpointIdentity identity = EndpointIdentity.CreateDnsIdentity("trustedserviceowner.somedomain.no"); var serviceEndpoint = new EndpointAddress(new Uri("https://kontaktinfo-ws-ver2.difi.no/kontaktinfo-external/ws-v3"), identity); var binding = new CustomBinding(); var securityBinding = SecurityBindingElement.CreateCertificateOverTransportBindingElement(MessageSecurityVersion.WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10); securityBinding.IncludeTimestamp = true; securityBinding.AllowInsecureTransport = true; binding.Elements.Add(securityBinding); binding.Elements.Add(new TextMessageEncodingBindingElement() { MessageVersion = MessageVersion.Soap11 }); binding.Elements.Add(new HttpsTransportBindingElement()); using (var factory = new ChannelFactory <oppslagstjeneste1405Channel>(binding, serviceEndpoint)) { var credentials = new MyClientCredentials(); SetupCertificates(credentials); factory.Endpoint.Behaviors.Remove(typeof(ClientCredentials)); factory.Endpoint.Behaviors.Add(credentials); var channel = factory.CreateChannel(); try { var forespoersel = new HentPersonerForespoersel(); forespoersel.informasjonsbehov = new informasjonsbehov[1]; forespoersel.informasjonsbehov[0] = informasjonsbehov.Kontaktinfo; forespoersel.personidentifikator = new string[personalNumber.Length]; for (var index = 0; index < personalNumber.Length; index++) { forespoersel.personidentifikator[index] = personalNumber[index]; } var request = new HentPersonerRequest(forespoersel); var response = channel.HentPersoner(request); channel.Close(); return(response); } catch { channel.Abort(); throw; } } }
private static HentPersonerRequest HentPersonerRequest() { var hentPersonForesp = new HentPersonerForespoersel(); hentPersonForesp.informasjonsbehov = new[] { informasjonsbehov.Kontaktinfo }; hentPersonForesp.personidentifikator = new[] { "31108446911" }; var hentPersonRequest = new HentPersonerRequest(null, hentPersonForesp); return(hentPersonRequest); }
public Person[] HentPersoner(HentPersonerForespoersel request) { Person[] response; using (var client = GetOppslagstjeneste1405Client()) { response = client.HentPersoner(request); client.Close(); } return(response); }
public Person[] Execute(HentPersonerForespoersel request) { Person[] response = null; var binding = CreateCustomBinding(); using (var client = new oppslagstjeneste1405Client("DifiOppslagstjeneste")) { client.Endpoint.Binding = binding; SetCredentials(client.ChannelFactory); response = client.HentPersoner(request); client.Close(); } return response; }
public void GetContactInfoFor2Persons_ShouldBeSuccessful() { var request = new HentPersonerForespoersel(); request.informasjonsbehov = new informasjonsbehov[1]; request.informasjonsbehov[0] = informasjonsbehov.Kontaktinfo; request.personidentifikator = new string[2]; request.personidentifikator[0] = "02018090573"; request.personidentifikator[1] = "02018090301"; var gateway = new HentPersonerGateway(CreateGatewaySettings()); var personer = gateway.Execute(request); Assert.IsNotNull(personer); Assert.AreEqual(2, personer.Length); Assert.AreEqual(request.personidentifikator[0], personer[0].personidentifikator); Assert.IsNotNull(personer[0].Kontaktinformasjon.Epostadresse.Value); Assert.AreEqual(request.personidentifikator[1], personer[1].personidentifikator); Assert.IsNotNull(personer[1].Kontaktinformasjon.Epostadresse.Value); }
public void HentPersoner() { var request = new HentPersonerForespoersel(); request.informasjonsbehov = new informasjonsbehov[1]; request.informasjonsbehov[0] = informasjonsbehov.Kontaktinfo; request.personidentifikator = new string[2]; request.personidentifikator[0] = "02018090573"; request.personidentifikator[1] = "02018090301"; var personer = _kontaktregisteretGateway.HentPersoner(request); Assert.IsNotNull(personer); Assert.AreEqual(2, personer.Length); Assert.AreEqual(request.personidentifikator[0], personer[0].personidentifikator); Assert.IsNotNull(personer[0].Kontaktinformasjon.Epostadresse.Value); Assert.AreEqual(request.personidentifikator[1], personer[1].personidentifikator); Assert.IsNotNull(personer[1].Kontaktinformasjon.Epostadresse.Value); }