Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF WebGetAttribute vs WebInvokeAttribute

Tags:

.net

wcf

webget

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

like image 710
puffpio Avatar asked Jul 02 '09 04:07

puffpio


People also ask

What is WebGet and WebInvoke in WCF?

February 8, 2019. 3 min read. The main difference between WebGet and WebInvoke is that WebGet is used to retrieve data while WebInvoke is used to update data. WCF stands for Windows Communication Foundation developed by Microsoft. It is used to develop service-oriented applications.

What is WebInvoke in WCF?

The WebInvoke attribute exposes services using other HTTP verbs such as POST, PUT, and DELETE. The default is to use POST, but it can be changed by setting the Method property of the attribute. These operations are meant to modify resources; therefore, the WebInvoke attribute is used to make modifications to resources.


1 Answers

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

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.

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.

like image 96
Thomas Beck Avatar answered Nov 16 '22 01:11

Thomas Beck