Yes, you can here, RESTful Web Services Design and Creation Guide
[ServiceContract] public partial class BookmarkService { [WebInvoke(Method = "PUT", UriTemplate = "users/{username}")] [OperationContract] void PutUserAccount(string username, User user) {...} [WebInvoke(Method = "DELETE", UriTemplate = "users/{username}")] [OperationContract] void DeleteUserAccount(string username) {...} [WebInvoke(Method = "POST", UriTemplate = "users/{username}/bookmarks")] [OperationContract] void PostBookmark(string username, Bookmark newValue) {...} [WebInvoke(Method = "PUT", UriTemplate = "users/{username}/bookmarks/{id")] [OperationContract] void PutBookmark(string username, string id, Bookmark bm) {...} [WebInvoke(Method = "DELETE", UriTemplate = "users/{username}/bookmarks/{id}")] [OperationContract] void DeleteBookmark(string username, string id) {...} ... }
For me, such a RESTful web service design is terrible. This ServiceContrcat:
- unsupported , fragile remote interface
- Too many methods to create.
- No polymorphism
I believe that the remote interface should be stable and flexible , we can use a message-based approach to design web services.
A detailed explanation can be found here: Creating RESTful Message Based Web Services with WCF , Code Samples Here: Nelibur and Nelibur nuget Package Here
source share