【问题标题】:How to consume post/put WCF RestFul Service如何使用 post/put WCF RestFul Service
【发布时间】:2015-03-29 17:10:41
【问题描述】:

我正在 wcf RESTful 服务中进行 crud 操作(使用存储过程)。我已经完成了创建服务,但是如何在我的 plain ASP.net 应用程序中使用该服务(没有 Javascript、Jquery、AJAX) 。由于我是WCF休息服务的新手。请给我一步一步的操作。

【问题讨论】:

    标签: asp.net c#-4.0 wcf-rest


    【解决方案1】:
             string sURL =  @"http://localhost:50353/urUriName/"+ txtfname.Text;
            WebRequest webGETURL;
    
            webGETURL = WebRequest.Create(sURL);
           webGETURL.Method = "DELETE"; 
           webGETURL.ContentType = @"Application/Json; charset=utf-8";
          HttpWebResponse wr = webGETURL.GetResponse() as HttpWebResponse;
           Encoding enc=Encoding.GetEncoding("utf-8");
        // read response stream from response object
        StreamReader loResponseStream = new StreamReader(wr.GetResponseStream(), enc);
    
        // read string from stream data
        string strResult = loResponseStream.ReadToEnd();
    
        // close the stream object
        loResponseStream.Close();
        // close the response object
        wr.Close();
        // assign the final result to text box
        Response.Write(strResult);
    

    【讨论】:

      猜你喜欢
      • 2012-05-29
      • 1970-01-01
      • 1970-01-01
      • 2012-08-07
      • 2011-04-29
      • 2021-01-29
      • 1970-01-01
      • 2011-08-30
      • 1970-01-01
      相关资源
      最近更新 更多