SOAP Web 服务和 RESTFUL Web 服务之间的区别

发布于 2024-12-06 12:01:48 字数 224 浏览 0 评论 0原文

我是Java新手。我知道有两种类型的Web服务

  1. SOAP Webservice。
  2. RESTful Web 服务。

任何人都可以告诉我它们两者之间的基本区别是什么。以及在哪种情况下创建 SOAP Webservice 以及在哪种情况下创建 RESTful Webservice

谢谢你,

I am new to Java.I know that there are two types of web service

  1. SOAP Webservice.
  2. RESTful Webservice.

can any one please tell me what is the basic difference between both of them.And in which situation the SOAP Webservice is created and in which situation RESTful Webservice is created.

Thank You,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

瑕疵 2024-12-13 12:01:49

在非常基础的层面上,SOAP 是一种消息传递协议,REST 是一种设计理念,而不是一种协议。当您基于 SOAP 协议构建 WebService 时,您基本上遵守以下 SOAP 规则:创建服务请求、将请求发布到服务器、在服务器接收请求、处理请求并以 SOAP 消息的形式返回结果。SOAP 不说话。关于客户端从服务中受益的确切方式,也不关于如何设计客户端本身(除了它发布的消息),它只告诉如何将来自客户端的消息发送到服务并返回。

REST 是表述性状态转移的缩写。它没有指定创建消息并将其发布到服务器的规则。您可以通过简单的 HTTP 协议来完成此操作。 REST 指定的是客户端和服务器管理其状态的方式,以便它们对客户端 - 服务器通信有用。在这里,您更专注于设计客户端和服务器的状态,而不是它们交换的消息。

At a very basic level , SOAP is a messaging protocol , REST is a design philosophy , not a protocol. When you base a WebService on a SOAP protocol , you basically comply with SOAP rules of creating a Service Request , posting the request to server , receiving the request at server , processing the request and returning the results as a SOAP message.SOAP does not talk about the exact manner in which client benefits from the service, nor about how to design the client itself ( apart from the message it is posting ), it only tells how a message from client can be sent to service and back.

REST is short for REpresentational State Transfer. It does not specify the rules to create a message and post it to server. You can do this by simple HTTP protocol. What REST specifies is the manner in which client and server manage their states so that they become useful to the client -server communication. Here , you are more focussed on designing the states of clients and servers rather than the messages they are exchanging.

旧夏天 2024-12-13 12:01:49

正如第一个答案已经解释的那样,SOAP Web 服务和 REST Web 服务在很多方面有所不同。

SOAP:

  • 您在 .wsdl 文件中定义接口,该文件准确地描述了需要哪些输入参数以及返回值的外观,就像
  • 有工具可以从 java 类层次结构中生成 .wsdl 文件一样。 例如 JAXB
  • 还有一些工具可以生成 java 对象/类作为 eclipse 的一部分(目前不知道名称) )。
  • SOAP 非常严格。每个请求在处理之前都会根据 wsdl 进行验证。

SOAP WS 的一个很好但不太容易上手的框架是 Apache CXF

REST(到目前为止还没有实践经验,请随意纠正和改进;) ):

  • 一种访问网络服务器或网络应用程序以从中检索数据或向其发送数据的方法。
  • 它只是协商如何访问它。
  • 常见的是这样的 http://server.domain.com/app/type/id=123检索 id=123 类型的对象
  • 非常直观,但没有自动验证请求。
  • ...

我确信,我还遗漏了其他几点。但我认为这是一个有用的开始。

As the first answer allready explains, SOAP Webservices and REST Webservices differ in various points.

SOAP:

  • you define your interface in a .wsdl file, which describes exactly which input parameters are expected and how the return values will look like
  • there are tools to generate the .wsdl files out of java class hirarchies. JAXB for example
  • there are also tools to generate java objects/classes as part of eclipse for example (don't know the name in the moment).
  • SOAP is very strict. Every request is validatet against the wsdl before processing.

A good but not so easy to start with framework for SOAP WS is Apache CXF

REST (no hands on experience up to now, feel free to correct and improve ;) ):

  • a way to access a webserver or web application to retrieve data from or send to it.
  • it's only negotiated, how it is accessed.
  • common is something like this http://server.domain.com/app/type/id=123 to retrieve object of type type with id=123
  • very intuitive, but no automatic validation of requests.
  • ...

I am sure, there are several other points I missed. But I think it's a usefull start.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文