JAX-RS和JAX-WS有什么区别? [英] What is the difference between JAX-RS and JAX-WS?

查看:122
本文介绍了JAX-RS和JAX-WS有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在阅读了有关JAX-RS和JAX-WS的几篇文章之后,我有几个要确认的问题?

After reading a few articles about JAX-RS and JAX-WS, I had a few questions that I want to confirm?

  1. JAX-RS可以像JAX-WS一样执行异步请求吗?
  2. JAX-RS是否可以访问未在Java平台上运行的Web服务,反之亦然?
  3. "REST对于PDA和移动电话等受限配置的设备特别有用"是什么意思?
  4. "JAX-RS不需要XML消息或WSDL服务–API定义是什么意思?

推荐答案

JAX-RS可以像JAX-WS一样执行异步请求吗?

Can JAX-RS do Asynchronous Request like JAX-WS?

1)我不知道JAX-RS API是否包括用于异步请求的特定机制,但是此答案仍会根据您使用的客户端实现而改变.

1) I don't know if the JAX-RS API includes a specific mechanism for asynchronous requests, but this answer could still change based on the client implementation you use.

JAX-RS是否可以访问未在Java平台上运行的Web服务,反之亦然?

Can JAX-RS access a web service that is not running on the Java platform, and vice versa?

2)我想不出它无法实现的任何原因.

2) I can't think of any reason it wouldn't be able to.

"REST对于PDA和移动电话等有限配置的设备特别有用"是什么意思?

What does it mean by "REST is particularly useful for limited-profile devices, such as PDAs and mobile phones"?

3)基于REST的体系结构通常将使用轻量级数据格式(如JSON)来回发送数据.这与使用XML的JAX-WS相反.我不认为XML本身比JSON这么重(有人可能会争论),但是对于JAX-WS,使用多少XML最终使使用JSON的REST成为更轻松的选择.

3) REST based architectures typically will use a lightweight data format, like JSON, to send data back and forth. This is in contrast to JAX-WS which uses XML. I don't see XML by itself so significantly heavier than JSON (which some people may argue), but with JAX-WS it's how much XML is used that ends up making REST with JSON the lighter option.

"JAX-RS不需要XML消息或WSDL服务–API定义是什么意思?

What does it mean by "JAX-RS do not require XML messages or WSDL service–API definitions?

4)如第3节所述,REST体系结构通常使用JSON发送和接收数据. JAX-WS使用XML.并不是说JSON本身比XML小得多.大多数情况下,JAX-WS规范在其通信方式上都包含很多开销.

4) As stated in 3, REST architectures often use JSON to send and receive data. JAX-WS uses XML. It's not that JSON is so significantly smaller than XML by itself. It's mostly that JAX-WS specification includes lots overhead in how it communicates.

关于WSDL和API定义,REST将更频繁地使用URI结构和HTTP命令来定义API,而不是像JAX-WS那样定义消息类型.这意味着您无需发布WSDL文档,以便服务的其他用户可以知道如何与服务对话.使用REST,您仍然需要向其他用户提供有关REST服务的组织方式以及需要发送哪些数据和HTTP命令的一些文档.

On the point about WSDL and API definitions, REST will more frequently use the URI structure and HTTP commands to define the API rather than message types, as is done in the JAX-WS. This means that you don't need to publish a WSDL document so that other users of your service can know how to talk to your service. With REST you will still need to provide some documentation to other users about how the REST service is organized and what data and HTTP commands need to be sent.

这篇关于JAX-RS和JAX-WS有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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