I\'m experimenting with WCF and built a standard product class with id and name parameters, my goal is to receive it from rest, and return status.
[DataContract
We should create Restful style WCF service by using webhttpbinding. Please refer to the below configuration.
Then we should specify the webmessagebodystyle.
[OperationContract]
[WebInvoke(BodyStyle =WebMessageBodyStyle.Bare)]
void GetData(Product product);
Assumed that there is the below definition.
[DataContract]
public class Product
{
[DataMember]
public int ID { get; set; }
[DataMember]
public string Name { get; set; }
}
We could call the service like the below way in Postman(please pay attention to the namespace of the custom class).
Please refer to my previous reply related to the WebMessageBodyStyle property.
Get the object is null using JSON in WCF Service
Feel free to let me know if the problem still exists.