Reputation: 318
I have seen this many times, where in a solution, there is a ASP.NET website, and a WCF consumed only by that website? What is the advantage of adding the web service versus having the website accessing the database directly? The website can do everything that the web service do, isn't it redundant?
Upvotes: 1
Views: 121
Reputation: 1753
SOA is the advantage. http://en.wikipedia.org/wiki/Service-oriented_architecture
Consider this example. your website is providing 3 services, like userservice1, userservice2 and userservice3. and each service contain following steps to interact with database. userservice1: login, connectionconfig, servicedataexchange1. userservice2: login, connectionconfig, servicedataexchange2. userservice3: login, connectionconfig, servicedataexchange3. and servicedataexchange contain variou activity or action like, servicedataexchange1: con1, dataexch1, dataexch0 servicedataexchange2:con2,dataexch1,dataexch2,dataexch0 servicedataexchange3:con1 dataexch0
Now for implementing these 3 services without webservice u need to write redundant programms with redundant methods. Thats why my friend you will implement webservice to avoid this redundancy.
Like you have to write one login mehod or one con1 method etc and each service can use that whenever it is required.
And noboday has seen future, what if you required to consume or host few services out of your network from other server, then you have to implement this architecture anyways.
Upvotes: 0
Reputation: 69270
If the site and the service are hosted on the same machine, it definitely looks like an overworked architecture to me.
One possible reason to do it is if the web service keeps some kind of state/cache or does background tasks that you don't want to get aborted when the app pool of the web site is recycled.
But generally, it just looks like bad design/architecture.
Upvotes: 2
Reputation: 2335
It depends what you want to because it is a massive topic. We tend to use WCF where we wish to maintain separation of concerns between our presentation and business logic/data layers. It also means we can host our service on a different server from that hosting the website, which is handy from a security and performance perspective.
Security wise WCF is far better at handling encryption of your traffic and you can do it without any real work by using the wsHttp protocol.
If all you are doing is a very simple website then a WCF service is certainly overkill, but as you get more complicated - especially if database data is involved then it becomes more and more appealing.
Upvotes: 2