WebInvoke方法= WCF上的REST服务的"POST"或"GET"

Nic*_*ahn 7 wcf

什么时候应该使用post vs get?在WCF上的REST服务中,下面是我的界面

       [OperationContract]
       [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
       string DoLodge(string Id, Lodge value);

       [OperationContract]
       [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
       LodgeLevel[] GetLodgeLevels(string Id);

       [OperationContract]
       [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
       long GetLodgeCount(string Id);
Run Code Online (Sandbox Code Playgroud)

Jus*_*ner 15

将更新发送回服务器时应使用POST.

从服务器检索对象时应使用GET.

您可能想要了解HTTP动词在RESTful服务上下文中的含义:


Dar*_*rov 7

每次修改服务器上的某些状态时都要POST,如数据库更新,删除.GET用于只读取数据库选择.