When should a web service not be used?

后端 未结 7 856
予麋鹿
予麋鹿 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 22:58

    Just because the tool generates a bunch of stubs doesn't mean it's a good use. WS-* excels in scenarios where you expose services to external parties. This means that each operation should be on the granularity of business process as opposed to data access.

    The multitude of standards can be used to describe different facets of your contract in great detail and a (hypothetical) fully compliant WS stack can take away a lot of pain from the third party developers and even allow the fabled point and click integration a'la Yahoo Pipes. With good governance controls you can evolve your public interface and manage the backward compatibility as needed.

    All this is next to impossible to be generated automatically. The C# stub generator knows only the physical interface of your class, but doesn't have any idea about the semantics involved. See this paper for more detailed discussion.

    If you are building a web site, then build a web site. If you want asynchronous messaging inside your application, use MSMQ. If you want to expose data to internal clients, use POX. If you need efficient binary message format, check Google's Protocol Buffers or if you need RPC check Hessian for C# or DCOM.

    Web services are a coarse grained integration solution. They are rigid, they are slower than alternatives, they take too much effort to do well (and when not done well are next to pointless).

    To summarize: "When should a web service not be used?" - anytime you can get away without it

提交回复
热议问题