When should a web service not be used?

后端 未结 7 840
予麋鹿
予麋鹿 2020-11-30 22:21

Using a web service is often an excellent architectural approach. And, with the advent of WCF in .Net, it\'s getting even better.

But, in my experience, some people

相关标签:
7条回答
  • 2020-11-30 23:15

    Web Services are an absolutely horrible choice for data access. It's a ton of overhead and complexity for almost zero benefit.

    If your app is going to run on one machine, why deny it the ability to do in-process data access calls? I'm not talking about directly accessing the database from your UI code, I'm talking about abstracting your repositories away but still including their assemblies in your running web site.

    There are cases where I'd recommend web services (and I'm assuming you mean SOAP) but that's mostly for interoperability.

    The granularity of the services is also in question here. A service in the SOA sense will encapsulate an operation or a business process. Data access methods are only part of that process.

    In other words:

      - someService.SaveOrder(order);  // <-- bad
        // some other code for shipping, charging, emailing, etc
    
      - someService.FulfillOrder(order);  //<-- better
        //the service encapsulates the entire process
    

    Web services for the sake of web services is irresponsible programming.

    0 讨论(0)
提交回复
热议问题