WebInvoke 方法=“POST"或“GET";用于 WCF 上的 REST 服务 [英] WebInvoke Method=“POST” or "GET" for a REST Service on WCF

查看:54
本文介绍了WebInvoke 方法=“POST"或“GET";用于 WCF 上的 REST 服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

When should use post vs get? in a REST service on WCF?, below is my interface

       [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.

POST should be used when sending an update back to the server.

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

GET should be used when retrieving an object from the server.

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

You might want to read up on what the HTTP Verbs mean in the context of RESTful services:

这篇关于WebInvoke 方法=“POST"或“GET";用于 WCF 上的 REST 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆