I am trying to POST JSON to a WCF service. The json object contains a property and an array. The problem is the TripleTransaction is always null when the request arrives at the server. I'm wondering how to correctly bind to my data contract. If anyone can give me a pointer here I would really appreciate it.
This is what my service interface looks like:
[OperationContract]
[CorsBehavior]
[WebInvoke(Method = "POST", UriTemplate = "Triples/{library}", ResponseFormat = WebMessageFormat.Json)]
ResultMessage InvokeGraphTransactions(string library, TripleTransaction tripleTransaction);
I am attempting to populate the TripleTransaction with the POSTed JSON. TripleTransaction contains a list of TripleModel.
[DataContract]
public class TripleTransaction
{
[DataMember]
public string Localization { get; set; }
[DataMember]
public List<TripleModel> Transactions { get; set; }
}
[DataContract]
public class TripleModel
{
[DataMember]
public int TransactionType { get; set; }
[DataMember]
public string SubjectLocalPart { get; set; }
[DataMember]
public string PredicateLocalPart { get; set; }
[DataMember]
public string ObjectPart { get; set; }
[DataMember]
public string Update { get; set; }
}
The above datacontract is modeled like the POSTed JSON. Using FireBug I can see that the request looks correct. The JSON is in the message payload and the request header has a contentType: application/json
This is an example of the json that I am attempting to send:
{
"tripleTransaction": {
"Localization": "en-us",
"Transactions": [
{
"TransactionType": 0,
"SubjectLocalPart": "testSubject",
"PredicateLocalPart": "testPredicate",
"ObjectPart": "1",
"Update": "2"
},
{
"TransactionType": 1,
"SubjectLocalPart": "testSubject",
"PredicateLocalPart": "testPredicate",
"ObjectPart": "1"
}
]
}
}