I was wondering if the [OperationContract] attribute is required? I created a new API endpoint and forgot to specify this attribute above the method, however, I was still able to successfully access this endpoint through Postman. I was wondering if this was expected behavior? I recall reading that methods in the [ServiceContract] are essentially opt-in, so shouldn't this endpoint not be accessible without that attribute?
Also, does the same reasoning apply to the [DataContract] attribute? Plenty of classes, that will be used to send a response to the caller, have not been decorated with this attribute.
This is related to the .Net framework. If you use .Net Framework 3.5, you need to add OperationContract to WCF REST API. But if you use .Net framework 4.0 or above, you can avoid adding OperationContract,because .Netframework 4.0 and later versions of WebInvoke implement IOperationContractAttributeProvider.
This is WebInvoke in .Net framework 4.0. You can see that it implements the IOperationContractAttributeProvider interface.
This is WebInvoke in .Net framework 3.5.