您好我发现了一个带有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();
Run Code Online (Sandbox Code Playgroud)
我的问题是,我可以使用WEBGET方法而不是WEBINVOKE,就像下面的WEBINVOKE POST和WEBGET之间的差别一样,根据我的观察,我们通过在WEAPGet和WebInvoke POST的URI模板中附加查询字符串来发送参数,使用WEBGET我们无法获得的WebInvoke POST有什么优势
[OperationContract]
[WebGet(
BodyStyle=WebMessageBodyStyle.Bare,
RequestFormat=WebMessageFormat.Xml,
ResponseFormat=WebMessageFormat.Xml,
UriTemplate="CreateStudent/{StudentName}/{Chair}/{AverageNote}")]
int Insert(string StudentName, string Chair, string AverageNote);
Run Code Online (Sandbox Code Playgroud)