I would really like to know the reason why one approach does not work and the other - but I just do not have time for some further digging. {: ABOUT (
Anyway, this is what I found.
A failure occurs when the contents of a request are created using the following
HttpContent content = HttpContentExtensions.Create(root, Encoding.UTF8, "text/xml");
But it works correctly when you create such content ...
HttpContent content = HttpContent.Create(root.ToString(), Encoding.UTF8, "text/xml");
The last working function is this:
/// <summary> /// Validate the user credentials held as member variables /// </summary> /// <returns>True if the user credentials are valid, else false</returns> public bool ValidateUser() { bool valid = false; try { // Create the XML to be passed as the request XElement root = BuildRequestXML("LOGON"); // Add the action to the service address Uri serviceReq = new Uri(m_ServiceAddress + "?obj=LOGON"); // Create the client for the request to be sent from using (HttpClient client = new HttpClient()) { // Initalise a response object HttpResponseMessage response = null;
Thanks.
source share