I know the argument was faced so many times, but I am a newbie and I don't understand how to manage the error.
I've a Stream XML and I would like to deserialize it with data contract method.
Do you notice where I'm making something wrong?
Here is the xml:
<?xml version="1.0"?>
<response>
<sessid>jsh5ekqnt39117tmu5gjebkku4</sessid>
<session_name>Name Session</session_name>
<user>
<uid>2</uid>
<vID>1</vID>
<roleId>1</roleId>
<username>mail@example.com</username>
<password>password</password>
<dateCreation>2013-05-14 00:00:00</dateCreation>
<dateLastLogin>2013-09-06 09:22:10</dateLastLogin>
<enabled>1</enabled>
<multisession>1</multisession>
<iddID>4</iddID>
<iddName>Nome</iddName>
<iddSurname>Cognome</iddSurname>
<iddMobile>32222222</iddMobile>
<iddEmail>mail@mail.mi</iddEmail>
<iddTelephone></iddTelephone>
<iddFax></iddFax>
<iddNotice></iddNotice>
<roles>manager</roles>
</user>
<result>1</result>
</response>
Here is the data contract:
namespace XmlAnalyzer.Ws {
[Serializable()]
public class LoginResponseContract {
[System.Xml.Serialization.XmlElement("uid")]
public string Uid { get; set; }
[System.Xml.Serialization.XmlElement("username")]
public string Username { get; set; }
[System.Xml.Serialization.XmlElement("iddName")]
public string Name { get; set; }
[System.Xml.Serialization.XmlElement("iddSurname")]
public string Surname { get; set; }
}
}
Here is the code:
HttpWebResponse response = (HttpWebResponse)_webRequest.GetResponse();
Stream responseStream = response.GetResponseStream();
XmlSerializer xs = new XmlSerializer(typeof(LoginResponseContract));
LoginResponseContract loginResponseContract = (LoginResponseContract)xs.Deserialize(streamXmlAuthentication);
This is the exception:
The request was aborted: The connection was closed unexpectedly.