-
Notifications
You must be signed in to change notification settings - Fork 2
ComparisonToOtherFrameworks
I built this after spending a long time trying to find a way to build REST web services that seemed natural to me, and handled all the framework-type stuff (format encoding) itself.
With that in mind, I have looked at many other projects:
I have previously been involved with a commercial product that used WCF to provide combined XML, JSON and SOAP APIs using one codebase, and while it (eventually) worked, it was nothing but problems and getting it configured simply feels like fighting with the framework, not to mention every deployment required some battling with WCF to get it working in the environment.
I could go in-depth, but suffice to say that WCF does not appeal to me from very many aspects.
This is a great project, and has a lot of the features I was looking for. It's also well maintained and has an active community. It definitely gave me a lot of inspiration, and I think Demis is doing a great job with it.
The underlying philosophy of ServiceStack is that REST is about performing actions on resources, with I agree with. However, the implementation is that the URLs get mapped to resources (DTO's), which in turn have a service implemented as RestService<MyModel>
, which ServiceStack then uses reflection to find.
My first issue with this is just in the convoluted nature of actually working with it. It takes an extra mental step to map the URLs I want to the code that will run them. I think this may just be me personally, and that the idea behind ServiceStack is the URLs are inconsequential, but every time I try to build something with it I find I get very irritated by this.
The second issue is that you either end up having a LOT of DTOs for your requests, or your DTOs are full of unused members. I'll put some code examples here eventually but basically if you have two different services that both take a userId as a parameter (for example, a service that returns the details about a user, and a service that returns a list of comments by that user), you need to have two different DTOs. The preferred way of ServiceStack seems to be to use the User DTO for the CRUD operations (which means in your GET /user/id method, you just have to ignore all the other properties in the User DTO as they don't get populated, even though they're passed). The other way requires writing two DTOs that are identical (with just a userId property) but different names. It all seems like a lot of ceremony just to get a simple service working.
I also take issue with the implementation of SOAP. Yes, it's possible to service SOAP but it only works with POST requests. This means if you want to make your entire API available using SOAP, all your operations have to be POST, and you're no longer RESTful.
I think this project is mostly unknown, but this actually is a great project towards what I want to achieve. I basically started building services on this, and adding more and more stuff, before I decided I should somehow incorperate it into the framework.
As I got doing this, I realized there were some ways to simplify things, and that my project would actually be a very major refactor at the very least, so for now at least, I started working on NServiceMVC.
The biggest difference is really that my services have a strongly-typed return value (istead of ActionResult
) and that a base controller is providing a hook to do formatting instead of using global filters to intercept the model before it's passed to the view engine. The downside is that you have to inherit from NServiceMVC.ServiceController, but the upside is you get strong typing and the framework code is much simpler.
At first glance, Web API has an incredibly similar syntax. The sample code is actually almost identical. The biggest difference is really that the API sets up a controller as a "resource" and then defines methods for GET/POST/etc, whereas NServiceMVC does not define any semantics for this and instead lets you define resources however you'd like and link them to methods.
TODO: deeper comparison