Sorry for a very simple question, I can't seem to find an answer. I'm trying to write a datacontract for a WCF service to receive the following xml:
<?xml version="1.0"?>
<CachedAwiData QReference="3" QAttempt="0" QReservation="{D6154D1C-6D42-4AA5-9FAC-217B2F9FE096}">
<CachedAwiDataRecord>
<CustRef><![CDATA[1]]></CustRef>
<Details><![CDATA[Hello World]]></Details>
<PrefDay><![CDATA[Monday]]></PrefDay>
<PrefTime><![CDATA[8.00am - 9.00am]]></PrefTime>
<Priority><![CDATA[Urgent]]></Priority>
<Trade><![CDATA[Plasterer]]></Trade>
</CachedAwiDataRecord>
</CachedAwiData>
so far I have tried a couple of things and got as far as:
[DataContract(Namespace = "")]
public class CachedAwiData
{
}
[DataContract(Namespace = "")]
public class CachedAwiDataRecord : CachedAwiData
{
[DataMember]
public string CustRef { get; set; }
}
I've got as far as getting a response that seems to get a null value for CustRef:
<ResponseData xmlns="http://schemas.datacontract.org/2004/07/RestService" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><CustRef i:nil="true" /></ResponseData>
I'm assuming its to do with my DataContract but perhaps I'm missing something here. Any clues greatly appreciated or am I best just going back to XML Serializer?
I don't think the inheritance is right. I don't use DataContracts much but I think you need something like
[DataContract(Namespace = "")]
public class CachedAwiData
{
[DataMember]
public CachedAwiDataRecord DataRecord;
}
[DataContract(Namespace = "")]
public class CachedAwiDataRecord
{
[DataMember]
public string CustRef { get; set; }
}