I'm experimenting with WCF RESTful web services and I'm having a problem with Auto-Implemented properties.
I have a class called DeviceDescriptor, defined as follows:
public class DeviceDescriptor
{
public string DeviceId { get; set; }
public string DisplayName { get; set; }
}
I have a RESTful WCF service that is supposed to return a List of DeviceDescriptors - here's my service contract:
[ServiceContract]
public interface IChooser
{
[WebGet(UriTemplate="/Chooser/RegisteredDevices")]
[OperationContract]
List<DeviceDescriptor> RegisteredDevices();
[WebGet(UriTemplate = "/Chooser/Ping")]
[OperationContract]
string Ping();
}
Well, it sort of works, except that in the XML output, the property names don't come out right, it looks like the serializer is using the "unutterable names" of the auto-generated backing fields instead of the property names. My output comes out like this:
<DeviceDescriptor>
<_x003C_DeviceId_x003E_k__BackingField>Pipe.Dome</_x003C_DeviceId_x003E_k__BackingField>
<_x003C_DisplayName_x003E_k__BackingField>Pipe diagnostic tool</_x003C_DisplayName_x003E_k__BackingField>
</DeviceDescriptor>
So, is there a way out of this? Why doesn;t WCF use the property names?