I defined a WCF implementation of REST service:
enter code here
[ServiceContract]
public interface IService
{
[OperationContract]
[WebGet(UriTemplate = "customers/{id}", ResponseFormat = WebMessageFormat.Json)]
Customer GetCustomer(string id);
[OperationContract]
[WebInvoke(UriTemplate = "customers", ResponseFormat = WebMessageFormat.Json)]
Customer PostCustomer(Customer c);
}
public class Service : IService
{
public Customer GetCustomer(string id)
{
return new Customer { ID = id, Name = "Demo User" };
}
public Customer PostCustomer(Customer c)
{
return new Customer { ID = c.ID, Name = "Hello, " + c.Name };
}
}
[DataContract(Namespace = "")]
public class Customer
{
[DataMember]
public string ID { get; set; }
[DataMember]
public string Name { get; set; }
}
The Get operation is easy. Without proxy generation on the client side, I am not sure how to consume the POST service. Any code sample will be appreciated!