【发布时间】:2011-09-02 10:32:54
【问题描述】:
嗨,我找到了一个带有 WEBINVOKE 方法的 wcf REST 示例,如下所示
[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,WEBINVOKE POST 和 WEBGET 之间到底有什么区别, 根据我的观察,我们通过在 URI 模板中为 WEBGet 和 WebInvoke POST 附加查询字符串来发送参数,使用 WebInvoke POST 可以获得哪些使用 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);
【问题讨论】: