您好我發現的WCF REST的例子一用一WEBINVOKE方法就像下面優勢相比WEBGET
[OperationContract]
[WebInvoke(
BodyStyle=WebMessageBodyStyle.Bare,
Method="POST",
RequestFormat=WebMessageFormat.Xml,
ResponseFormat=WebMessageFormat.Xml,
UriTemplate="CreateStudent/{StudentName}/{Chair}/{AverageNote}")]
int Insert(string StudentName, string Chair, string AverageNote);
[OperationContract]
[WebGet(
BodyStyle= WebMessageBodyStyle.Bare,
RequestFormat = WebMessageFormat.Xml,
ResponseFormat = WebMessageFormat.Xml)]
Student[] GetAllStudents();
我的問題是,我可以使用WEBGET方法,而不是WEBINVOKE就像下方根據我的觀察,我們通過在URI模板中爲WEbGet和WebInvoke POST追加查詢字符串來發送參數,我們可以使用WebInvoke POST獲得哪些優勢,我們可以根據我的觀察發現WEBINVOKE POST和WEBGET之間的差異究竟是什麼沒有得到使用WEBGET
[OperationContract]
[WebGet(
BodyStyle=WebMessageBodyStyle.Bare,
RequestFormat=WebMessageFormat.Xml,
ResponseFormat=WebMessageFormat.Xml,
UriTemplate="CreateStudent/{StudentName}/{Chair}/{AverageNote}")]
int Insert(string StudentName, string Chair, string AverageNote);
很好地解釋了...... – 2012-11-27 06:25:49
除非您正在創建的Web服務需要接受跨域Ajax調用 - 在這種情況下,GET對於數據檢索和修改都是必需的。在跨域AJAX情況下不允許POST。 – 2013-07-05 00:00:06
這是一張完美的圖片! – iamCR 2014-07-04 04:28:51