标签:
使用WebClient调用WCF服务
流程:从View获取实体类-->序列化-->写入内存流中-->传给远端的WCF服务
Get、POST、PUT、DELETE
using (WebClient wc = new WebClient())
{
MemoryStream ms = new MemoryStream();
DataContractJsonSerializer serializerToUplaod = new DataContractJsonSerializer(typeof(Customer));
serializerToUplaod.WriteObject(ms, id);
wc.Headers["Content-type"] = "application/json";
wc.UploadData(customerServiceUri + "DeleteCustomer", "DELETE", ms.ToArray());
}
http://www.codeproject.com/Articles/788580/WCF-RESTful-service-and-WebGrid-in-ASP-NET-MVC-P
http://www.codeproject.com/Articles/788583/WCF-RESTful-service-and-WebGrid-in-ASP-NET-MVC-Par
http://www.codeproject.com/Articles/35982/REST-WCF-and-Streams-Getting-Rid-of-those-Names-Sp
[转]WCF RESTful service and WebGrid in ASP.NET MVC 5
标签:
原文地址:http://www.cnblogs.com/gossip/p/4246890.html