I'm new to WCF (and pretty rusty with .NET in general), so we have a great chance, this is the answer to the question, and I just missed it.
I am creating an ASP.NET MVC application that will use the RESTful JSON API for its backend. I have studied various options for talking to such an API in .NET, and it seems that WCF is the most popular choice to date. Reading in WCF a little more Now I have a base consumer class that makes a request, which is the beginning.
But now I need to do more with this, and I am not moving forward. I need to send a POST to an API with a JSON body. Here is what I still have:
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Runtime.Serialization;
namespace APIConsumer {
[ServiceContract]
public interface IAPIClient {
[OperationContract]
[WebInvoke(
Method = "POST",
BodyStyle = WebMessageBodyStyle.Bare,
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "/session/login.json"
)]
string SessionLogin(string login_name);
}
public class APIClient : ClientBase<IAPIClient>, IAPIClient {
public string SessionLogin(string login_name) {
return this.Channel.SessionLogin(login_name);
}
}
}
, , a) POST b) .NET- JSON POST. , -?