I am currently implementing a web service with the ASP.net Web API and one of my methods returns a string. The problem is it returns the string like this:
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization">Some Resource</string>
This kind of response is what I want, but I don’t know how to deserialise it in my web service client.
How would you deserialise any xml representing a string or any primitive datatype?
Thanks!
You can use ReadAsAsync from the System.Net.Http.Formatting.dll. Say
‘uri’ will get me this data:
Then you can use ReadAsAsync to get the string in the XML:
(I’m calling .Result directly to demonstrate the use of ReadAsAsync<> here…)