- 浏览: 1090924 次
文章分类
- 全部博客 (379)
- S2SH (16)
- stuts2 (0)
- java语言 (81)
- JSP (17)
- <html>元素 (11)
- javaweb (4)
- web容器 (3)
- ext (23)
- javaScript (48)
- ant (1)
- liferay (1)
- sql (9)
- css (42)
- 浏览器设置 (3)
- office_world (1)
- eclipse (4)
- 其它 (28)
- 操作系统 (5)
- android (6)
- Struts2 (11)
- RegEx (3)
- mysql (5)
- BigDATA (1)
- Node.js (1)
- Algorithm (10)
- Apache Spark (1)
- 数据库 (5)
- linux (2)
- git (1)
- Adobe (3)
- java语言,WebSocket (1)
- Maven (3)
- SHELL (1)
- XML (2)
- 数学 (2)
- Python (2)
- Java_mysql (1)
- ReactJS (6)
- 养生 (4)
- Docker (1)
- Protocols (3)
- java8 (2)
- 书籍 (1)
- Gradle (2)
- AngularJS (5)
- SpringMVC (2)
- SOAP (1)
- BootstrapCSS (1)
- HTTP协议 (1)
- OAuth2 (1)
最新评论
-
Lixh1986:
Java并发编程:自己动手写一把可重入锁https://blo ...
Java之多线程之Lock与Condition -
Lixh1986:
http://win.51apps.com.cn/https: ...
temp -
ztwsl:
不错,支持很好
HttpServletRequest和ServletRequest的区别 -
guodongkai:
谢谢您能将知识精华汇编总结,让初学者们从原理中学会和提高。
javaScript之function定义 -
kangwen23:
谢谢了,顶顶
struts2中的ValueStack学习
Understanding SOAP and REST Basics And Differences
January 8, 2013 by John Mueller
一、背景知识
1、什么是 WebService ?
-
Web 上的 Service。
谁的 Service? 对象不是人。是机器。
人通过Web获取的信息都是利于人阅读的。而 WebService 提供的信息是利于机器阅读的。
所以 WebService 的全名是: Application Web Service 。面向应用的web服务。
-
为什么需要 WebService?
可以提供系统与系统间的通信。可以构建复杂的分布式系统。
-
WebService 只是一个抽象的概念。只要能够提供面向应用的web服务,都可以成为 WebService。
它可以用 Java 实现,可以用 .NET 实现。
本文只针对 Java 实现。
二、SOAP VS. REST
Simple Object Access Protocol (SOAP) and Representational State Transfer (REST) are two answers to the same question: how to access Web services. The choice initially may seem easy, but at times it can be surprisingly difficult.
实现 WebService 的方式中, SOAP 和 REST 是其中两种。选择哪一种乍看起来简单,但是多数情况下,其实相当困难。
SOAP is a standards-based Web services access protocol that has been around for a while and enjoys all of the benefits of long-term use. Originally developed by Microsoft, SOAP really isn’t as simple as the acronym would suggest.
SOAP是基于规范的一种 WebService 实现协议。(注意:这里的协议不属于网络七层协议,而是用户用于数据传输而自定义的协议。SOAP 是所有自定义协议的统称。)SOAP已经使用了一段时间,带来了很大方便,并有初具规模的长期服务。SOAP 最初由 Microsoft 开发。SOAP 并不像它简称上写的那样简单。
__________________________________________________________________________________
关于 RESTful :
-
Representational State Transfer
which state ? The state of object.
-
Representational State of Object Transfer
对象的表示化状态-传输。 (表示成什么呢?文本)
比较专业的翻译: 具象状态传输 (对象的状态具文本象,传输)
把如此专业的概念说的如此抽象。不就是字符串么?不仅仅是。
字符串只是对象的一种象。对象的象还可以是二进制字节流。
但,RESTful 目前只支持字符串,貌似。
-
_________________________________________________________________________________
三、The Difference between SOAP vs REST APIs
REST is the newcomer to the block. It seeks to fix the problems with SOAP and provide a truly simple method of accessing Web services. However, sometimes SOAP is actually easier to use; sometimes REST has problems of its own. Both techniques have issues to consider when deciding which protocol to use.
REST 是新来的。它寻求解决 SOAP 的不足和问题,提供了一种够简单的 WebService 的实现方案,然而,特定情况下 SOAP 使用起来更简单。 REST 也有自己的不足。当选择时,它们各自的问题和不足都要考虑到。
Before I go any further, it’s important to clarify that while both SOAP and REST share similarities over the HTTP protocol, SOAP is a more rigid set of messaging patterns than REST. The rules in SOAP are important because without these rules, you can’t achieve any level of standardization. REST as an architecture style does not require processing and is naturally more flexible. Both SOAP and REST rely on well-established rules that everyone has agreed to abide by in the interest of exchanging information.
在继续讨论之前,首先声明:SOAP 是基于协议的。它在交换数据时必须同时携带定义数据的协议数据。虽然 SOAP 和 REST 在使用 HTTP 协议上有相同点,但是 SOAP 是硬性要求传递数据解析的格式。如果这些格式缺失或被省略,SOAP 无法工作。而 REST 则是一种构建模式形式,不硬性要求信息的解析处理,所以原生更灵活。当然,两者都需要知道数据的格式才可以数据的交换。
A Quick Overview of SOAP
SOAP relies exclusively on XML to provide messaging services. Microsoft originally developed SOAP to take the place of older technologies that don’t work well on the Internet such as the Distributed Component Object Model (DCOM) and Common Object Request Broker Architecture (CORBA). These technologies fail because they rely on binary messaging; the XML messaging that SOAP employs works better over the Internet.
After an initial release, Microsoft submitted SOAP to the Internet Engineering Task Force (IETF) where it was standardized. SOAP is designed to support expansion, so it has all sorts of other acronyms and abbreviations associated with it, such as WS-Addressing, WS-Policy, WS-Security, WS-Federation, WS-ReliableMessaging, WS-Coordination, WS-AtomicTransaction, and WS-RemotePortlets. In fact, you can find a whole laundry list of these standards on Web Services Standards.
The point is that SOAP is highly extensible, but you only use the pieces you need for a particular task. For example, when using a public Web service that’s freely available to everyone, you really don’t have much need for WS-Security.
The XML used to make requests and receive responses in SOAP can become extremely complex. In some programming languages, you need to build those requests manually, which becomes problematic because SOAP is intolerant of errors. However, other languages can use shortcuts that SOAP provides; that can help you reduce the effort required to create the request and to parse the response. In fact, when working with .NET languages, you never even see the XML.
Part of the magic is the Web Services Description Language (WSDL). This is another file that’s associated with SOAP. It provides a definition of how the Web service works, so that when you create a reference to it, the IDE can completely automate the process. So, the difficulty of using SOAP depends to a large degree on the language you use.
One of the most important SOAP features is built-in error handling. If there’s a problem with your request, the response contains error information that you can use to fix the problem. Given that you might not own the Web service, this particular feature is extremely important; otherwise you would be left guessing as to why things didn’t work. The error reporting even provides standardized codes so that it’s possible to automate some error handling tasks in your code.
An interesting SOAP feature is that you don’t necessarily have to use it with the HyperText Transfer Protocol (HTTP) transport. There’s an actual specification for using SOAP over Simple Mail Transfer Protocol (SMTP) and there isn’t any reason you can’t use it over other transports. In fact, developers in some languages, such as Python and PHP, are doing just that.
A Quick Overview of REST
Many developers found SOAP cumbersome and hard to use. For example, working with SOAP in JavaScript means writing a ton of code to perform extremely simple tasks because you must create the required XML structure absolutely every time.
REST provides a lighter weight alternative. Instead of using XML to make a request, REST relies on a simple URL in many cases. In some situations you must provide additional information in special ways, but most Web services using REST rely exclusively on obtaining the needed information using the URL approach. REST can use four different HTTP 1.1 verbs (GET, POST, PUT, and DELETE) to perform tasks.
Unlike SOAP, REST doesn’t have to use XML to provide the response. You can find REST-based Web services that output the data in Command Separated Value (CSV), JavaScript Object Notation (JSON) and Really Simple Syndication (RSS). The point is that you can obtain the output you need in a form that’s easy to parse within the language you need for your application.
As an example of working with REST, you could create a URL for Weather Underground. The API’s documentation page shows an example URL of http://api.wunderground.com/api/Your_Key/conditions/q/CA/San_Francisco.json. The information you receive in return is a JSON formatted document containing the weather for San Francisco. You can use your browser to interact with the Web service, which makes it a lot easier to create the right URL and verify the output you need to parse with your application.
Deciding Between SOAP and REST
Before you spend hours fretting over the choice between SOAP and REST, consider that some Web services support one and some the other. Unless you plan to create your own Web service, the decision of which protocol to use may already be made for you. Extremely few Web services, such as Amazon, support both. The focus of your decision often centers on which Web service best meets your needs, rather than which protocol to use.
Soap Vs Rest
SOAP is definitely the heavyweight choice for Web service access. It provides the following advantages when compared to REST:
- Language, platform, and transport independent (REST requires use of HTTP)
- Works well in distributed enterprise environments (REST assumes direct point-to-point communication)
SOAP 可以传递序列化的对象,二进制数据流。该特点在分布式环境中发挥的很好。
REST 目前的支持的数据传递格式为字符文本。故只能是点对点传输。
- 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 is easier to use for the most part and is more flexible. It has the following advantages when compared to 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
-
转载请注明,
原文出处:http://lixh1986.iteye.com/blog/2346064
-
Java Web Service 20 问
January 8, 2013 by John Mueller
一、背景知识
1、什么是 WebService ?
-
Web 上的 Service。
谁的 Service? 对象不是人。是机器。
人通过Web获取的信息都是利于人阅读的。而 WebService 提供的信息是利于机器阅读的。
所以 WebService 的全名是: Application Web Service 。面向应用的web服务。
-
为什么需要 WebService?
可以提供系统与系统间的通信。可以构建复杂的分布式系统。
-
WebService 只是一个抽象的概念。只要能够提供面向应用的web服务,都可以成为 WebService。
它可以用 Java 实现,可以用 .NET 实现。
本文只针对 Java 实现。
二、SOAP VS. REST
Simple Object Access Protocol (SOAP) and Representational State Transfer (REST) are two answers to the same question: how to access Web services. The choice initially may seem easy, but at times it can be surprisingly difficult.
实现 WebService 的方式中, SOAP 和 REST 是其中两种。选择哪一种乍看起来简单,但是多数情况下,其实相当困难。
SOAP is a standards-based Web services access protocol that has been around for a while and enjoys all of the benefits of long-term use. Originally developed by Microsoft, SOAP really isn’t as simple as the acronym would suggest.
SOAP是基于规范的一种 WebService 实现协议。(注意:这里的协议不属于网络七层协议,而是用户用于数据传输而自定义的协议。SOAP 是所有自定义协议的统称。)SOAP已经使用了一段时间,带来了很大方便,并有初具规模的长期服务。SOAP 最初由 Microsoft 开发。SOAP 并不像它简称上写的那样简单。
__________________________________________________________________________________
关于 RESTful :
-
Representational State Transfer
which state ? The state of object.
-
Representational State of Object Transfer
对象的表示化状态-传输。 (表示成什么呢?文本)
比较专业的翻译: 具象状态传输 (对象的状态具文本象,传输)
把如此专业的概念说的如此抽象。不就是字符串么?不仅仅是。
字符串只是对象的一种象。对象的象还可以是二进制字节流。
但,RESTful 目前只支持字符串,貌似。
-
_________________________________________________________________________________
三、The Difference between SOAP vs REST APIs
REST is the newcomer to the block. It seeks to fix the problems with SOAP and provide a truly simple method of accessing Web services. However, sometimes SOAP is actually easier to use; sometimes REST has problems of its own. Both techniques have issues to consider when deciding which protocol to use.
REST 是新来的。它寻求解决 SOAP 的不足和问题,提供了一种够简单的 WebService 的实现方案,然而,特定情况下 SOAP 使用起来更简单。 REST 也有自己的不足。当选择时,它们各自的问题和不足都要考虑到。
Before I go any further, it’s important to clarify that while both SOAP and REST share similarities over the HTTP protocol, SOAP is a more rigid set of messaging patterns than REST. The rules in SOAP are important because without these rules, you can’t achieve any level of standardization. REST as an architecture style does not require processing and is naturally more flexible. Both SOAP and REST rely on well-established rules that everyone has agreed to abide by in the interest of exchanging information.
在继续讨论之前,首先声明:SOAP 是基于协议的。它在交换数据时必须同时携带定义数据的协议数据。虽然 SOAP 和 REST 在使用 HTTP 协议上有相同点,但是 SOAP 是硬性要求传递数据解析的格式。如果这些格式缺失或被省略,SOAP 无法工作。而 REST 则是一种构建模式形式,不硬性要求信息的解析处理,所以原生更灵活。当然,两者都需要知道数据的格式才可以数据的交换。
A Quick Overview of SOAP
SOAP relies exclusively on XML to provide messaging services. Microsoft originally developed SOAP to take the place of older technologies that don’t work well on the Internet such as the Distributed Component Object Model (DCOM) and Common Object Request Broker Architecture (CORBA). These technologies fail because they rely on binary messaging; the XML messaging that SOAP employs works better over the Internet.
After an initial release, Microsoft submitted SOAP to the Internet Engineering Task Force (IETF) where it was standardized. SOAP is designed to support expansion, so it has all sorts of other acronyms and abbreviations associated with it, such as WS-Addressing, WS-Policy, WS-Security, WS-Federation, WS-ReliableMessaging, WS-Coordination, WS-AtomicTransaction, and WS-RemotePortlets. In fact, you can find a whole laundry list of these standards on Web Services Standards.
The point is that SOAP is highly extensible, but you only use the pieces you need for a particular task. For example, when using a public Web service that’s freely available to everyone, you really don’t have much need for WS-Security.
The XML used to make requests and receive responses in SOAP can become extremely complex. In some programming languages, you need to build those requests manually, which becomes problematic because SOAP is intolerant of errors. However, other languages can use shortcuts that SOAP provides; that can help you reduce the effort required to create the request and to parse the response. In fact, when working with .NET languages, you never even see the XML.
Part of the magic is the Web Services Description Language (WSDL). This is another file that’s associated with SOAP. It provides a definition of how the Web service works, so that when you create a reference to it, the IDE can completely automate the process. So, the difficulty of using SOAP depends to a large degree on the language you use.
One of the most important SOAP features is built-in error handling. If there’s a problem with your request, the response contains error information that you can use to fix the problem. Given that you might not own the Web service, this particular feature is extremely important; otherwise you would be left guessing as to why things didn’t work. The error reporting even provides standardized codes so that it’s possible to automate some error handling tasks in your code.
An interesting SOAP feature is that you don’t necessarily have to use it with the HyperText Transfer Protocol (HTTP) transport. There’s an actual specification for using SOAP over Simple Mail Transfer Protocol (SMTP) and there isn’t any reason you can’t use it over other transports. In fact, developers in some languages, such as Python and PHP, are doing just that.
A Quick Overview of REST
Many developers found SOAP cumbersome and hard to use. For example, working with SOAP in JavaScript means writing a ton of code to perform extremely simple tasks because you must create the required XML structure absolutely every time.
REST provides a lighter weight alternative. Instead of using XML to make a request, REST relies on a simple URL in many cases. In some situations you must provide additional information in special ways, but most Web services using REST rely exclusively on obtaining the needed information using the URL approach. REST can use four different HTTP 1.1 verbs (GET, POST, PUT, and DELETE) to perform tasks.
Unlike SOAP, REST doesn’t have to use XML to provide the response. You can find REST-based Web services that output the data in Command Separated Value (CSV), JavaScript Object Notation (JSON) and Really Simple Syndication (RSS). The point is that you can obtain the output you need in a form that’s easy to parse within the language you need for your application.
As an example of working with REST, you could create a URL for Weather Underground. The API’s documentation page shows an example URL of http://api.wunderground.com/api/Your_Key/conditions/q/CA/San_Francisco.json. The information you receive in return is a JSON formatted document containing the weather for San Francisco. You can use your browser to interact with the Web service, which makes it a lot easier to create the right URL and verify the output you need to parse with your application.
Deciding Between SOAP and REST
Before you spend hours fretting over the choice between SOAP and REST, consider that some Web services support one and some the other. Unless you plan to create your own Web service, the decision of which protocol to use may already be made for you. Extremely few Web services, such as Amazon, support both. The focus of your decision often centers on which Web service best meets your needs, rather than which protocol to use.
Soap Vs Rest
SOAP is definitely the heavyweight choice for Web service access. It provides the following advantages when compared to REST:
- Language, platform, and transport independent (REST requires use of HTTP)
- Works well in distributed enterprise environments (REST assumes direct point-to-point communication)
SOAP 可以传递序列化的对象,二进制数据流。该特点在分布式环境中发挥的很好。
REST 目前的支持的数据传递格式为字符文本。故只能是点对点传输。
- 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 is easier to use for the most part and is more flexible. It has the following advantages when compared to 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
-
转载请注明,
原文出处:http://lixh1986.iteye.com/blog/2346064
-
Java Web Service 20 问
发表评论
-
java 将文件夹所有的文件合并到指定的文件夹下
2020-06-30 19:17 978场景:将文件夹所有的文件合并到指定的文件夹下 另外:如果想效 ... -
多线程-线程池的四种创建方式
2020-04-01 18:38 410多线程-线程池的四种创建方式 https://blog.cs ... -
Java基础之:nio
2019-11-13 15:38 414一、理论讲解: 史上最强Java NIO入门:担心从入门到放弃 ... -
Java 分布式之:RPC 基本概念
2019-11-13 15:07 402转载: https://www.jianshu.com/p/ ... -
Java之 volatile 关键字原理详解
2019-11-07 15:36 444一、什么是 volatile ? ... -
POI实现excell批注背景图片(仿html浮窗显示图片)
2019-10-21 08:17 602POI实现excell批注背景图片(仿html浮窗显示图片) ... -
Java之设计模式之 Observer 观察者
2019-07-04 17:21 972观察者设计模式 Java 已经实现了该模式,并且提供了使用类 ... -
HashMap, LinkedHashMap and TreeMap
2019-03-01 11:04 624https://stackoverflow.com/a/177 ... -
Java lib 操作 excel 插入图片
2019-01-19 12:46 838https://poi.apache.org/componen ... -
数据库连接池C3P0
2018-05-29 16:50 811一、名字的由来 很多 ... -
Java8之集合(Collection)遍历 forEach()、stream()
2018-05-29 14:39 20658package java8.collections; ... -
Junit Vs main on "java.util.concurrent.Executors"
2017-11-10 16:44 734Same code with different result ... -
Java之大数据学习路线
2017-11-03 10:08 5673三个月大数据研发学习 ... -
Java中创建对象的5种方式
2017-10-26 14:21 805一、Java之5种创建对象的方式 ————————————— ... -
Log4j和Slf4j的比较
2017-06-23 12:41 1361一直搞不清 Log4j 和 SLF4j 的关系。今天才若有所 ... -
Java之Java7新特性之try资源句式
2017-04-20 14:58 5338Java之Java7新特性之try资源句式 一、【try资源 ... -
Java之 java.util.concurrent 包之ExecutorService之submit () 之 Future
2017-03-04 21:27 3772一、如何使用 ExecutorService.submit() ... -
Java之 java.util.concurrent 包之Executor与ExecutorService
2017-03-04 21:18 2644一、问题: execute() 与 submit() 的区别? ... -
JAVAEE之单用户登录
2017-02-05 11:55 1032单用户登录是系统中数据一直性的解决方案之一。 问题背景: 试 ... -
Java之多线程之线程池之线程重复使用
2017-02-04 13:33 5522一、问题背景 在使用多线程时,如果要开启一个任务,则就需要新 ...
相关推荐
SOAP webserivce 和 RESTful webservice 对比及区别.pdfSOAP webserivce 和 RESTful webservice 对比及区别.pdf
基于REST的软件体系结构风格(Software Architecture Style)称之...按照REST原则设计的软件、体系结构,通常被称为“REST式的”(RESTful),在本文中以下称之为 RESTful Web服务,以便于和基于SOAP的Web服务区别。
什么是REST,符合REST的API叫RESTful 两种SOA接口实现:SOAP(WebService) vs REST
基于 cxf 2.7.5 开发的 webservice [soap restful]
启动后访问http://localhost:8080/cxf-ws-restful-spring-server/ws63
RESTful webservice 和 SOAP webserivce 对比及区别
Java restful和webservice接口, WebService有两种方式,一是SOAP方式,二是REST方式。SOAP是基于XML的交互,WSDL也是一个XML文档,可以使用WSDL作为SOAP的描述文件;REST是基于HTTP协议的交互,支持JSON、XML等交互...
结合网上的例子,在本地搭建并且跑通了的基于CXF的例子,soap webservice 和 restful webservice的混搭模式. 依赖cxf 3.0.4 测试工具SOAPUI 5.0 服务器 tomcat 7 浏览器 chrome
使用jax-ws和jax-rs ,maven、java、spring 分别创建soap类型的webservice和restful类型的webservice,文档附有代码
RESTful WebService是比基于SOAP消息的WebService简单的多的一种轻量级Web服务,RESTful WebService是没有状态的,发布和调用都非常的轻松容易。 下面写一个最简单的Hello World例子,以便对RESTful WebService有...
kong-plugin-soap2rest 插件,用于将SOAP请求重定向到REST API并将JSON响应转换为SOAP响应。 目录 兼容的Kong版本 港版 测试通过 2.3.x :check_mark_button: 2.2.x :check_mark_button: 2.1.x :check_...
Addison.Wesley.Service.Design.Patterns.Fundamental.Design.Solutions.for.SOAP.WSDL.and.RESTful.Web.Services
Restful风格的WebService正在渐渐取代传统的SOAP, Java 也有很多Restful的框架,很方便简洁,Jersey,restlet,甚至SpringMVC也可以,不得不说Rest让人从Web转型到WebService更容易和方便,当然深入Restful的理论...
配置好数据库,放到tomcat访问 http://localhost:8080/Service wsdl:http://localhost:8080/Service/hello?wsdl wsal:http://localhost:8080/Service/rest?_wadl 访问rest实例:...
这些 Services 可以支持多种协议,比如:SOAP、XML/HTTP、RESTful HTTP 或者 CORBA ,并且可以在多种传输协议上运行,比如:HTTP、JMS 或者 JBI,CXF 大大简化了 Services 的创建,同时它继承了 XFire 传统,一样...
基于 WebService服务的开发 以Restful风格的编码为主导 案例包括 Ws和Rs两种代码编写 以及包含与Spring整合代码客户端和服务端的实现
这些 Services 可以支持多种协议,比如:SOAP、XML/HTTP、RESTful HTTP 或者 CORBA ,并且可以在多种传输协议上运行,比如:HTTP、JMS 或者 JBI,CXF 大大简化了 Services 的创建,同时它继承了 XFire 传统,一样...
spring + cxf + restful + soap 方便初学者很快上手。 注解描述 @Path注解的值是一个相对的URI路径,这个路径指定了该Java类的位置,例如/helloworld。在这个URI中可以包含变量,例如可以获取用户的姓名然后作为参数...
调用远程wadl的Webservice代码,请求参数是json,返回结果通过main方法打印
一个简单的基于SOAP headers的WebService式身份验证 通过通过SOAP Header身份验证。 通过集成windows身份验证。