WCF WebGetAttribute VS WebInvokeAttributeWebGetAttribute、WCF、WebInvokeAttribute、VS

2023-09-03 16:20:54 作者:用幸福触摸忧伤↗

时的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.

 
精彩推荐
图片推荐