public async Task Get_Paciente() { // When ReadRecordEnvelopeBody readRecordEnvelopeBody = new ReadRecordEnvelopeBody("SauPacienteData", "2;997852"); string envelope = EnvelopeBuilder(readRecordEnvelopeBody); var content = new StringContent(envelope, Encoding.UTF8, "text/xml"); httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, apiUrl); httpRequestMessage.Headers.Add("SOAPAction", "http://www.123456789.com.br/br/ReadRecordAuth"); httpRequestMessage.Content = content; // When var response = await httpClient.SendAsync(httpRequestMessage); var response_content = response.Content.ReadAsStringAsync().Result; // Then response.EnsureSuccessStatusCode(); Assert.Equal(HttpStatusCode.OK, response.StatusCode); xmlDocument.LoadXml(response_content); var content02 = xmlDocument.GetElementsByTagName("ReadRecordAuthResult"); var innerText = content02.Item(0).InnerText; xmlDocument.LoadXml(innerText); }
public static string EnvelopeBuilder(ReadRecordEnvelopeBody readRecordEnvelopeBody) { return($@"<soap:Envelope xmlns:soap=""http://www.w3.org/2003/05/soap-envelope"" xmlns:br=""http://www.123456789.com.br/br/""> <soap:Header/> <soap:Body> <br:ReadRecordAuth> <br:DataServerName>{readRecordEnvelopeBody.DataServerName}</br:DataServerName> <br:PrimaryKey>{readRecordEnvelopeBody.PrimaryKey}</br:PrimaryKey> <br:Contexto>{readRecordEnvelopeBody.Contexto}</br:Contexto> <br:Usuario>{readRecordEnvelopeBody.Usuario}</br:Usuario> <br:Senha>{readRecordEnvelopeBody.Senha}</br:Senha> </br:ReadRecordAuth > </soap:Body> </soap:Envelope>" ); }