首先我们先包装一个RestClient类,用于实现调用RESTful风格的Web服务,具体代码参考如下:
public class RestClient
{
/// <summary>
/// Request Uri String
/// </summary>
public string RequestUriString { get; set; }
/// <summary>
/// Request Method POST or GET ...
/// </summary>
public HttpVerb Method { get; set; }
/// <summary>
/// ContentType
/// </summary>
public string ContentType { get; set; }
/// <summary>
/// Post Data
/// </summary>
public string PostData { get; set; }
/// <summary>
/// Encoding
/// </summary>
public string Encoding { get; set; }
/// <summary>
/// 构造函数
/// </summary>
/// <param name="url">Rest 服务URL地址</param>
public RestClient(string url)
{
Reques
使用C#调用RESTful API的方法

本文介绍如何在C#中通过自定义的RestClient类调用RESTful风格的Web服务。通过示例代码展示调用过程。
最低0.47元/天 解锁文章
379

被折叠的 条评论
为什么被折叠?



