I am trying to read a response XML from a service to a class to use it.
if i use this URL https://btsvcs.college.edu/HR/Employee/ID/[email protected]
The response XML will be like this:
<Data>
<Record id="PA01051" rowOrder="0">
<employee_id>20000343</employee_id>
</Record>
</Data>
I had create my class to be the same with the response XML.
This is the class:
public class GetEmployeeIdByEmail
{
[DataContract(Namespace = "")]
public class Record
{
[DataMember(Order = 0)]
public string employee_id { get; set; }
}
[DataContract(Namespace = "")]
public class Data
{
[DataMember(Order = 0)]
public Record Record { get; set; }
}
}
After that i had make a function to read the XML using the HttpClient
This is the function:
public async Task<GetEmployeeIdByEmail> GetEmployeeIdByEmail()
{
var client = new HttpClient();
var url = "https://btsvcs.college.edu/HR/Employee/ID/[email protected]";
client.BaseAddress = new Uri(url);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/xml"));
var responseMessage = await client.GetAsync(url);
GetEmployeeIdByEmail responseData = null;
if (responseMessage.IsSuccessStatusCode)
{
responseData = await responseMessage.Content.ReadAsAsync<GetEmployeeIdByEmail>();
}
return responseData;
}
If I make a break point on this function and tracking it step by step always get back to website to read the xml after this line
var responseMessage = await client.GetAsync(url); and no response back to complete the debugging.
I don't know what is reason for that.
no response back? Clarify.