如何使用 post/put WCF RestFul 服务
How to consume post/put WCF RestFul Service
我正在 wcf restful 服务中执行 crud 操作(使用存储过程)。我已经创建了服务,但是如何在我的 plain [=16= 中使用该服务] 应用程序(没有 Javascript、Jquery、AJAX)。由于我是WCF的新手,rest service.Plz给我一步一步的操作。
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);
我正在 wcf restful 服务中执行 crud 操作(使用存储过程)。我已经创建了服务,但是如何在我的 plain [=16= 中使用该服务] 应用程序(没有 Javascript、Jquery、AJAX)。由于我是WCF的新手,rest service.Plz给我一步一步的操作。
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);