何时使用Web服务

时间:2014-08-12 07:36:08

标签: java web-services rest soap

我是Web服务概念的新手,但我已经完成了很少的工作并实现了REST服务。我有几个问题

  1. Web服务是否仅用于跨平台通信?

  2. 何时使用SOAP或REST?我如何做出决定

  3. 网络服务有哪些优势

  4. 提前致谢

1 个答案:

答案 0 :(得分:5)

在花费数小时思考SOAP和REST之间的选择之前,请考虑一些Web服务支持一个和另一个。除非您计划创建自己的Web服务,否则可能已经决定使用哪种协议。极少数Web服务(如亚马逊)都支持这两种服务。您的决策重点往往集中在哪种Web服务最能满足您的需求,而不是使用哪种协议。

SOAP绝对是Web服务访问的重量级选择。与REST相比,它具有以下优势:

Language, platform, and transport independent (REST requires use of HTTP)
Works well in distributed enterprise environments (REST assumes direct point-to-point communication)
Standardized
Provides significant pre-build extensibility in the form of the WS* standards
Built-in error handling
Automation when used with certain language products

REST大部分都更容易使用,而且更灵活。与SOAP相比,它具有以下优点:

No expensive tools require to interact with the Web service
Smaller learning curve
Efficient (SOAP uses XML for all messages, REST can use smaller message formats)
Fast (no extensive processing required)
Closer to other Web technologies in design philosophy
相关问题