public async Task <ActionResult <Response> > GetPersonAsync(string firstName)
        {
            PersonServiceClient personClient = new PersonServiceClient();
            Response            response     = await personClient.GetPersonAsync(new Request { FirstName = firstName });

            return(Ok(new { response.ResponseMessage, response.PersonList }));
        }
Exemplo n.º 2
0
        public async Task <string> GetAsync(String id)
        {
            //Connect to service and get person
            PersonServiceClient client = new PersonServiceClient();

            LookupParameters lookupParameters = new LookupParameters();

            lookupParameters.NIN  = id;
            lookupParameters.Date = null;

            // var xml = @"<Invoice> <Timestamp>1/1/2017 00:01</Timestamp><CustNumber>12345</CustNumber><AcctNumber>54321</AcctNumber></Invoice>"; // test data
            var xml = await client.GetPersonAsync(lookupParameters);

            await client.CloseAsync();

            //XML to JSON
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml.ToString());
            String json = Newtonsoft.Json.JsonConvert.SerializeXmlNode(doc, Newtonsoft.Json.Formatting.Indented, true);

            //return JSON
            return(id + " " + json);
        }