简体   繁体   English

在Java世界中创建新的RPC / Web服务的最佳方法?

[英]Best approach for creating new RPC/web services in the Java world?

I think this question may end up being a bit subjective so I'm marking it as CW. 我认为这个问题可能最终有点主观,所以我把它标记为CW。

My team is interested in developing a new set of "web services" for our projects to use. 我的团队有兴趣为我们的项目开发一套新的“Web服务”。 I put "web services" in air-quotes since the term can mean so many different things. 我把“网络服务”放在空气报价中,因为这个术语可能意味着很多不同的东西。 The only thing we really need it to mean is that we can expose some set of APIs to cross-platform clients to consume our data and take action on it. 我们真正需要它的唯一意思是我们可以向跨平台客户端公开一些API来使用我们的数据并对其采取行动。

I'm attempting to do some research to understand what the current "state of the art" is when it comes to creating services for exposing your data to lots of other (internal) applications and even other services. 我正在尝试进行一些研究,以了解当前的“最新技术”是什么,在创建服务以将数据暴露给许多其他(内部)应用程序甚至其他服务时。 I've been researching things like Thrift, Protocol Buffers, JAX-WS, RMI, etc., and I'm kind of lost as far as figuring out what kind of approach we should take in designing a new set of services. 我一直在研究诸如Thrift,Protocol Buffers,JAX-WS,RMI等等的东西,而且我想知道在设计一组新服务时我们应采取什么样的方法。 I'd like for us to be able to essentially create an "infrastructure" for services, which is why I'm taking a bit of a survey of all current approaches. 我希望我们能够基本上为服务创建一个“基础设施”,这就是我对所有当前方法进行一些调查的原因。

For building brand-new-from-scratch web services, where does the current best practice / state of the art lie? 为了构建全新的从头开始的Web服务,当前最佳实践/最新技术在哪里?

Our only real requirements are: 我们唯一真正的要求是:

  • The data format/encoding should be platform independent (this rules out RMI). 数据格式/编码应该是平台无关的(这排除了RMI)。
  • Services should work well over HTTP 服务应该在HTTP上运行良好
  • Writing the actual server-side services in Java should not be a problem. 用Java编写实际的服务器端服务应该不是问题。
  • Being able to generate client proxies would be a nice plus. 能够生成客户端代理将是一个很好的加分。
  • I'd like each service to be light-weight, where we could conceivably deploy services for different functionality as completely separate deployments. 我希望每项服务都是轻量级的,我们可以设想将不同功能的服务部署为完全独立的部署。

We currently use some combination of SOAP and Axis/JAXRPC services and honestly these are a giant pain to work with - the messages sent back and forth are huge and overly verbose. 我们目前使用SOAP和Axis / JAXRPC服务的一些组合,老实说这些是一个巨大的痛苦 - 来回发送的消息是巨大的,过于冗长。

Have you considered a REST service ? 您考虑过REST服务吗? Here's a useful introduction from InfoQ . 这是InfoQ的一个有用的介绍。

It works over HTTP, and you use the standard HTTP commands of GET/PUT/POST/DELETE to manipulate data (you can query using browsers and clients are simple HTTP clients). 它适用于HTTP,您使用GET / PUT / POST / DELETE的标准HTTP命令来操作数据(您可以使用浏览器进行查询,客户端是简单的HTTP客户端)。 The actual data content is not mandated or specified - often it's XML but that's not a requirement. 实际的数据内容不是强制或指定的 - 通常是XML,但这不是必需的。

You can build REST services trivially under Java using Jersey . 您可以使用Jersey在Java下轻松构建REST服务。 Because the clients just need to talk HTTP they can be language-independent. 因为客户端只需要谈论HTTP,所以它们可以与语言无关。 Java clients can be written using HTTPClient . 可以使用HTTPClient编写Java客户端。

Probably too late but I'll try anyway. 可能为时已晚,但无论如何我都会尝试。 SOAP has long lost its first letter (Simple). SOAP早已失去了它的第一个字母(Simple)。 It never stood up to its second one (Object), either. 它也从未经受过它的第二个(对象)。

That's why I am leaning towards JSON-based services, either REST or JSON-RPC ones. 这就是为什么我倾向于基于JSON的服务,无论是REST还是JSON-RPC服务。 You got quite a few recommentations for the former already. 你已经为前者做了不少推荐。 For the latter you may want to look into Jabsorb.org . 对于后者,您可能需要查看Jabsorb.org As an example, OpenSocial standard uses both with the preference towards the JSON-RPC. 例如,OpenSocial标准使用两者优先于JSON-RPC。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM