Java REST 实现:Jersey 与 CXF

发布于 2024-08-30 06:52:00 字数 1436 浏览 3 评论 0原文

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

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

发布评论

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

评论(5

離殇 2024-09-06 06:52:00

我都使用过,但目的不同。 CXF 非常适合解析 WSDL 并创建用于交互的 Java POJO,因此 CXF 非常适合客户端 WSDL 服务。我目前正在使用 Jersey 进行服务器端实现,并且使用 Jersey 启动和运行 RESTful 服务的简单性给我留下了深刻的印象。

由于 Jersey 主要致力于 RESTful 服务,而 CXF 主要(全部?)处理 SOAP,我认为这取决于您是否想使用 SOAP 还是 REST,并从那里确定最适合工作的框架。就我个人而言,我更倾向于 REST 阵营而不是 SOAP,但我的需求不同。如果我的供应商/客户/公司需要某种合同来编写服务,我可能仍然会推动 REST(以及基于合同的服务的 REST 等效项,WADL),但可能需要实现 SOAP 服务,在这种情况下,我会首先查看 CXF,然后再查看其他所有内容。

就个人而言,Jersey 对于 JAX-RS 框架来说相当不错,尽管不排除 JBoss 的 RESTEasy。我都喜欢,但 RESTEasy 的文档更好。

对于 CXF,文档没问题,但我在处理 SSL 和 HTTP 代理时遇到了不一致的情况,但最终它自己解决了。 CXF 确实提供了更多关于这些附加功能的开箱即用的功能,我想说 RESTEasy 将为 RESTful 框架提供等效的功能。

I have used both, but for different purposes. CXF worked great to parse a WSDL and create Java POJOs to interact with, so CXF is pretty good for client-side WSDL services. I'm currently using Jersey for server-side implementation and I am impressed with the simplicity of getting up-and-running with RESTful services using Jersey.

As Jersey is mainly devoted to RESTful services and CXF deals mostly (all?) with SOAP, I think it comes down to whether you want to work with SOAP or REST, and determine the best framework for the job from there. Personally, I am more in the REST camp than SOAP, but my needs are different. Should I be in a situation where the vendor/customer/company I write the service for needs some sort of contract, I might still push for REST (and REST's equivalent for contract-based services, WADL), but would likely be required to implement a SOAP service, in which case I would look at CXF first and everything else second.

Personally, Jersey is pretty good for a JAX-RS framework, although don't exclude RESTEasy, by JBoss. I like both, but the documentation for RESTEasy is better.

For CXF, the documentation is OK, but I ran into inconsistencies in how I needed to handle SSL and HTTP Proxies, but it worked itself out eventually. CXF does provide more out of the box regarding these additional features, and I would say RESTEasy would provide the equivalent functionality for RESTful frameworks.

物价感观 2024-09-06 06:52:00

我只使用过泽西岛(非常满意),所以我无法给出真正的比较。您可能需要考虑的事项:

  • CXF 与 SOAP 堆栈打包在一起
    支持,所以你带来了很多
    你永远不会使用的与 SOAP 相关的权重
    当您构建 RESTful 系统时。
    (有计划拆分
    据我所知,包装)
  • 泽西岛有很多
    JAX-RS 的非标准补充
    非常有帮助。还有一个
    客户端核心框架是
    设计得相当不错。
  • 【警告:无耻塞进(抱歉)】:我已经
    正在开发泽西岛扩展客户端
    鼓励适当的侧面框架
    在客户端使用 REST,并且是
    (至少恕我直言)使用起来非常自然。
    计划于今年(或
    下)周 - 如果您关心
    客户端很多,尝试一下。
    就我个人而言,我认为这是一个巨大的
    支持泽西岛的论点。

HTH

简·

I have only used Jersey (with great satisfaction) so I cannot give a real comparison. Things you might want to consider:

  • CXF is packaged up with SOAP stack
    support so you bring in a lot of
    SOAP-related weight you'll never use
    when you build a RESTful system.
    (There are plans to split the
    packaging as far as I know, though)
  • Jersey comes with a number of
    non-standard additions to JAX-RS that
    are very helpful. There is also a
    client side core framework which is
    designed quite nicely.
  • [Warning: Shameless plug ahead (sorry)]: I have been
    working on an extended Jersey client
    side framework that encourages proper
    use of REST on the client side and is
    (IMHO at least) very natural to use.
    It is planned to announce it this (or
    next) week - if you care about the
    client side a lot, give it a try.
    Personally, I'd consider that a huge
    pro-Jersey argument.

HTH,

Jan

美人迟暮 2024-09-06 06:52:00

您是否考虑过RESTlet
它是一个功能强大的包,可以快速构建 RESTful Web 服务。 RESTlet 背后的人员还撰写了《RESTlet In Action》一书,该书目前处于抢先体验阶段。已经提供的章节很好地解释了 REST 并详细说明了如何设计 REST api。

Did you consider RESTlet?
It is a powerful package to quickly build RESTful web services. The people behind RESTlet also write the RESTlet In Action book which is currently in early access. The chapters that are already available do a very good job of explaining REST and detailing how you go about designing a REST api.

柳若烟 2024-09-06 06:52:00

如果您担心将使用Jersey开发的解决方案转换为在CXF上运行的细节,Glen Mazza 在 GitHub 上发布了移植到 Apache CXF 的 Jersey 示例集合。自述文件包含每个示例的有关必要更改的注释。

If you are concerned about the details of converting a solution developed with Jersey to run on CXF, Glen Mazza posted a collection of Jersey samples ported to Apache CXF on GitHub. The README files have notes for each sample regarding necessary changes made.

半枫 2024-09-06 06:52:00

我已经将 Apache CXF 用于 JAX-WS,将 Jersey 用于 JAX-RS,因此我无法评论 CXF 和 REST。使用 Jersey 可以轻松设置 REST 示例。文档是足够的。我没有使用过 RESTEasy,但 Jersey 看起来有更多的吸引力和更新的更新。

RESTful Web Services Cookbook 是一本关于实施指南的好书。

I've used Apache CXF for JAX-WS and Jersey for JAX-RS so I can't comment about CXF and REST. It was easy to set up a REST example using Jersey. The documentation was adequate. I haven't used RESTEasy but Jersey looks to have more traction and more recent updates.

A good book for implementation guidelines is RESTful Web Services Cookbook.

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