Click here to Skip to main content
15,880,972 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a data contracts as follows:

[DataContract]
[KnownType(typeof(UserData))]
[KnownType(typeof(CardData))]
[XmlRoot(Namespace = Constants.XML_NMSP_TXN_MSG, ElementName = Constants.XML_TAG_COMMAND)]
public class MessageData
{
[XmlAttribute("ID")]
[DataMember]
public long CommandId { get; set; }
[DataMember]
public object Data { get; set; }
}

[DataContract]
public class UserData
{
[DataMember]
public string UserId { get; set; }
[DataMember]
public string FirstName { get; set; }
}

[DataContract]
public class CardData
{
[DataMember]
public string CardId { get; set; }
[DataMember]
public string CardNumber { get; set; }
}

And service contract as:
[OperationContract]
[WebInvoke(
Method = "POST",
RequestFormat = WebMessageFormat.Xml,
ResponseFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "api/AddRequest/")]
string AddRequest(MessageData ReqData);

I am sending CardData and UserData as an object in MessageData.Data
The problem is I MessageData is not getting deserialized. Can anyone help me with this please?

Basically I want to use the AddRequest() method to send different data to the service. Is there another way to do it? Am i even doing it the right way?
Posted
Updated 7-Jan-14 3:18am
v3
Comments
Tejas Vaishnav 7-Jan-14 8:45am    
where is code to dematerialize your data?
gkishore84 7-Jan-14 9:10am    
I am sorry but I am not sure what you mean. The idea is to add the MessageData to a List using the AddRequest() method and later get data from the queue and use it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900