Question

Can you give me some examples of service oriented system built in Web Api? Currently I'm thinking about 2 approaches:

  • First is simple and straightforward - having each service in its own Web Application, hosted independently in IIS from each other. There are some reasons why I don't like it: every developer have to create Web Api projects and deploy on IIS on their own, no centralized Api Discovery, no centralized security mechanism and etc...

  • Second one is better I think, but also bitter complicated - having only 1 service endpoint, I call it Gateway, all of service calls go through this endpoint, and having "Plugin" style systems in particular folder call this "Plugins Folder", each new service will be deployed as a bunch of dll-s in this folder (No own service endpoints), And finally reading all controllers(for different services/projects of course) with Web Api's IAssemblyResolver from this folder.

If I choose the second method I have following advantages: each developer in my team can "publish" own services without touching WebApi, only copying their project's dll-s in "Plugins Folder". Also routing and Api discovery is very easy in this case, sample routing - {Application/ServiceName}/{version}/{controller}/{action}/{id}. I have centralized security control over system and etc.

Any suggestion or samples and tutorials will be appreciated.

I know SOA is platform and technology independent, but I didn't think better title.

Was it helpful?

Solution

Advantages of hosting the services as separate web applications are that they can scale independently and be on different release cycles. Other considerations though are cross domain issues if you are making ajax requests to your services. If they are hosted separately they will be on different domains, which means you have to do something like CORS, JSONP or reverse proxy to allow ajax request from the browser.

OTHER TIPS

You won't find too many articles on the web describing SOA using ASP.NET Web API, which I love using. Don't get caught up in comparisons between Web API and WCF, either (with the possible exception of REST aspects of WCF, but why bother, use Web API in such cases). A nice discussion is going on at ASP.NET Core with respect to WCF, https://github.com/dotnet/wcf/issues/1200. Keep an eye open for future .NET releases and WCF implemented features, regardless of how it is marketed.

I think you should be asking yourself if you want/need to host services in an SOA environment. Large companies, such as Insurance companies, that share APIs and do so behind a firewall will typically use SOA. If you don't need proxies to call into services which exist on application servers, you may not need a complex architecture. In this case ASP.NET Web API is probably a perfect solution. If you will be developing in a typical SOA environment, I would recommend WCF and .NET 4.6.2 for now, with future .NET releases to support WCF.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top