wcf - WCF 上的 REST 服务的 WebInvoke 方法 =“POST” 或 "GET"

标签 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);

最佳答案

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

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

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

  • http://swdeveloper.wordpress.com/2012/03/04/rest-for-the-rest-of-us/
  • http://homepages.tig.com.au/~ijoyner/Ian_Joyner/REST.html
  • 关于wcf - WCF 上的 REST 服务的 WebInvoke 方法 =“POST” 或 "GET",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4197956/

    相关文章:

    wcf - 在 HTTP GET 中将结构数组作为 WCF 方法参数传递

    c# - "Could not find endpoint element with name..."

    c# - 如何将对象注入(inject) WCF 的 IErrorHandler?

    c# - WCF、流、消息约定错误 : Error in deserializing body of request message

    WCF 列出实现某个合约的所有客户端端点

    c# - DocumentCollection.Open() 函数不工作 AutoCAD API

    c# - WCF 服务、Windows 身份验证

    c# - 从异步方法关闭 WCF 服务?

    上传大文件的 WCF 问题,托管在 IIS 中

    c# - 使用 REST 为带有图像的复杂对象提供服务