我需要学习Java中的Web服务.里面有什么不同的类型? [英] I need to learn Web Services in Java. What are the different types in it?

查看:42
本文介绍了我需要学习Java中的Web服务.里面有什么不同的类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我决定开始学习Java Web服务,并且当我开始在Google中搜索Java Web服务的教程时,我发现有很多类型的Web服务基于XML,基于SOAP以及RESTful Web服务.

Recently, I decided to start learning about java web services and when I started to search a tutorial for java web-services in google, I found out that there are many types of webservices XML based, SOAP based, also RESTful webservices.

此外,我发现有一个基于XML的Web服务的JAX-WS规范和一个用于创建RESTful Web服务的JAX-RS规范.

Also, I found that there is a JAX-WS specification for xml based web-services, and JAX-RS specification for creating RESTful webservices.

Q1)我很困惑,如果有人可以帮助我理解这些不同类型的Web服务之间的区别,以便我可以决定首先学习哪个,那将是非常棒的.

Q1) I got confused, it would be great if anybody can help me understanding the difference between these different type of webservices, so that I can decide which one to learn first.

Q2)另外,我想深入学习有关在Java中创建不同类型的Web服务的信息.是否有任何教程或资源可以深入了解每种类型的Web服务以及它们之间的比较.

Q2) Also, I want to learn in-depth about creating different types of web-services in java. Is there any tutorial or resources which can give an insight to each kind of webservice and a comparison between them.

Q3)基于什么情况和条件,我应该决定创建基于XML的Web服务而不是SOAP服务,还是应该使用RESTful服务.

Q3) based on what scenarios and conditions should I decide that I want to create an XML based web-service rather than a SOAP service or I should go with RESTful service.

推荐答案

  1. SOAP Web服务是基于标准的,并且几乎受每个软件平台的支持:它们高度依赖XML并具有支持用于事务,安全性,异步消息和许多其他问题.这是一个相当大而复杂的标准,但几乎涵盖了所有消息传递情况.另一方面, RESTful服务依靠HTTP协议和动词(GET,POST,PUT,DELETE)来交换消息.任何格式,最好是JSON和XML.这是一种非常简单而优雅的建筑方法.
  2. 与Java世界中的每个主题一样,有多个库可用于构建/使用Web服务.在SOAP方面,您具有 JAX-WS标准 Restlets 或<一个href ="http://static.springsource.org/spring/docs/3.0.0.M3/spring-framework-reference/html/ch18s02.html"> Spring REST设施和其他库.li>
  1. SOAP Web Services are standard-based and supported by almost every software platform: They rely heavily in XML and have support for transactions, security, asynchronous messages and many other issues. It’s a pretty big and complicated standard, but covers almost every messaging situation. On the other side, RESTful services relies of HTTP protocol and verbs (GET, POST, PUT, DELETE) to interchange messages in any format, preferable JSON and XML. It’s a pretty simple and elegant architectural approach.
  2. As in every topic in the Java World, there are several libraries to build/consume Web Services. In the SOAP Side you have the JAX-WS standard and Apache Axis, and in REST you can use Restlets or Spring REST Facilities among other libraries.

对于问题3,本文指出RESTful Services适用于这种情况:

With question 3, this article states that RESTful Services are appropiate in this scenarios:

  • 如果带宽有限
  • 如果您的操作是无状态的:从一次调用到下一次调用都不会保留任何信息,并且每个请求都将被独立处理.
  • 如果您的客户端需要缓存.

在以下情况下,SOAP是必经之路:

While SOAP is the way to go when:

  • 如果您需要异步处理
  • 如果您需要正式合同/接口
  • 服务中的操作是有状态的:例如,您将信息/数据存储在请求中,并在下一个请求中使用该存储的数据.

这篇关于我需要学习Java中的Web服务.里面有什么不同的类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆