XML : RestSharp's deserialization doesn't work, C# Serialization does

I've got some troubles with RestSharp's builtin deserialization.

My Code:

  RestClient client = new RestClient("https://example.com/rest/");    client.ClearHandlers();  client.AddHandler("application/xml", new RestSharp.Deserializers.XmlDeserializer());    var request = new RestRequest();  request.Resource = "member/findScoutIdsForOrganization/{organizationId}";  request.AddUrlSegment("organizationId", orgId);    var response = client.Execute<wsScoutIdList>(request);  var scoutids = response.Data;    XmlSerializer serializer = new XmlSerializer(typeof(wsScoutIdList));  var result = serializer.Deserialize(XmlReader.Create(new StringReader(response.Content)));    

wsScoutIdList.java: (generated by xsd2code++)

  [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.6.81.0")]  [System.SerializableAttribute()]  [System.Diagnostics.DebuggerStepThroughAttribute()]  [System.ComponentModel.DesignerCategoryAttribute("code")]  [System.Xml.Serialization.XmlRootAttribute("ScoutIdList", Namespace="", IsNullable=false)]  public partial class wsScoutIdList  {        private List<string> _list;        public wsScoutIdList()      {          this._list = new List<string>();      }        [System.Xml.Serialization.XmlElementAttribute("list", Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=true)]      public List<string> list      {          get          {              return this._list;          }          set          {              this._list = value;          }      }  }    

xml:

  <?xml version ="1.0" encoding="UTF-8" standalone="yes" ?>  <ScoutIdList>      <list>id1</list>      <list>id2</list>      <list>id3</list>  </ScoutIdList>    

System.XML.Serialization works, but RestSharp doesn't. The list is simply empty.

I also tried json, not working either.

No comments:

Post a Comment