Is the WebGetAttribute just syntactic sugar for the WebInvokeAttribute with Method = "GET"? Or is there an underlying difference?
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With