WCF WebGetAttribute VS WebInvokeAttribute [英] WCF WebGetAttribute vs WebInvokeAttribute

查看:918
本文介绍了WCF WebGetAttribute VS WebInvokeAttribute的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

时的WebGetAttribute只是语法糖与方法=的WebInvokeAttributeGET? 还是有一个基本的区别是什么?

Is the WebGetAttribute just syntactic sugar for the WebInvokeAttribute with Method = "GET"? Or is there an underlying difference?

推荐答案

您直接观察到WebGet和WebInvoke非常相似是不是从事实都太远。 WebGet,因为你已经指出,适用于HTTP GET动词,而WebInvoke可以适用于所有其他动词(PUT,POST,DELETE,等等)。

Your immediate observation that WebGet and WebInvoke are very similar is not all too far from the truth. WebGet, as you've already stated, applies to the HTTP GET verb while WebInvoke can be used to apply to all the other verbs (PUT, POST, DELETE, etc).

在许多的WebInvoke参数,反映那些WebGet。 BodyStyle,RequestFormat,ResponseFormat和UriTemplate都是present为WebGet和WebInvoke。一个区别是方法参数WebInvoke的presence。方法参数指定对应于操作,与邮政为默认值的HTTP动作

Many of the parameters in WebInvoke mirror those in WebGet. BodyStyle, RequestFormat, ResponseFormat, and UriTemplate are all present for both WebGet and WebInvoke. The one differentiator is the presence of the "Method" parameter for WebInvoke. The Method parameter specifies the HTTP verb that corresponds to the operation, with POST being the default value.

我还没有使用反射来看看引擎盖WebGet和WebInvoke下的机会,但我怀疑他们是非常相像,即使他们似乎只是共享System.Attribute作为一个共同的血统。

I haven't had the chance to use Reflector to look under the hood for WebGet and WebInvoke but I suspect that they are very much alike even though they only seem to share System.Attribute as a common lineage.

这篇关于WCF WebGetAttribute VS WebInvokeAttribute的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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