SypeInfeffink
New Member
Does anyone know whether it is possible to have 2 different endpoints using 2 different Contract Serializers? Particularly, the default DataContractSerializer for SOAP/XML and Json.NET serializer for REST/JSONThe aim (due compatibilities issues) is to have the same DTO class Person below, serialized into the following JSON and XML formatsDTO Class:\[code\]public class Person{ public string Name { get; set; } public string Surname { get; set; }}\[/code\]JSON\[code\]{Psn:{"Nm":"name1","Snm":"surname1"}}\[/code\]XML\[code\]<Person><Name>name1</Name><Surname>surname1</Surname></Person>\[/code\]As can be seen, Response for JSON should contain shrunk property names, but full property names for XML version.My thoughts were to have both serialisation annotations, those understood by the DataContractSerialiser and those understood by Json.Net serializer i.e. something of this sort:\[code\][DataMember][JsonObject(Title="Psn")]public class Person{ [DataMember] [JsonProperty(PropertyName="Nm")] public string Name { get; set; } [DataMember] [JsonProperty(PropertyName="Snm")] public string Surname { get; set; }}\[/code\]I would appreciate any thoughts on how this can be achieved.