Regarding XML deserialization
Hi,I am using the below code to de-serialize my response fetched from server.
StringContent stringContent = new StringContent(result, Encoding.UTF8, "text/xml");
// Sends the request and wait for response
HttpResponseMessage response = await httpClient.PostAsync(uri, stringContent);
response.EnsureSuccessStatusCode();
// Deserialize response
XmlSerializer serializer = new XmlSerializer(typeof(Responses));
try
{
Responses responses = (Responses)serializer.Deserialize(await response.Content.ReadAsStreamAsync());
}
catch (Exception ex)
{
}
The Response format is:
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:Header/>
<soap-env:Body>
<n0:_-SIE_-PD_FMROMDResponse xmlns:n0="urn:sap-com:document:sap:rfc:functions">
<ET_LOG>
<item>
data comes here
</item>
</ET_LOG>
</n0:_-SIE_-PD_FMROMDResponse>
</soap-env:Body>
</soap-env:Envelope>
The code in try block shows the error "Envelope xmlns='http //schemas.xmlsoap.org/soap/envelope/' was not expected." I have even stated XMLRoot attribute ( [XmlRoot(Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]) on Response class level.
Could anyone please let me know what could be the issue here.
Thanks in advance.