本文介绍了java 休息客户端:jax-rs &自动类型映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我想要做的:

创建一个接口(例如):

Create an interface (as an example):

@Path( "/" )
public interface Bubbles {

   @Get
   @Path( "blowBubble" )
   @Produces( "text/plain" )
   Bubble blowBubble();
}

所述接口应该部署为一个宁静的网络服务.在这一点上我不是特别关心服务器端,我主要关心客户端.

Said interface should be deployed as a restful web service. I don't particularly care too much about the server side at this point, I mainly concerned with the client.

我正在寻找一个我可以找到的图书馆:

What I am looking for is a library where I can:

1)实现接口,接口不知道完整的URL(知道服务器和端口显然是必要的(毕竟在接口中)

1) Implement the interface, without the interface knowing the full URL (knowing the server and port is obviously necessary (it is in the interface after all)

2) 通过线路自动将Bubble"映射到 json.无需向其中添加 JAXB,无需构建类型转换器等自动

2) Automatically map 'Bubble' to json across the wire. No adding JAXB to it, no building type converters, etc automatically

我的问题是,我使用的 2 个库可以执行 1 或另一个,但不能同时执行 :(

My problem is that the 2 libraries I have used do 1 or the other, but not both :(

Restlet 库做了 2 但不是 1,CXF 做了 1 但不是 2.

The Restlet library does 2 but not 1, CXF does 1 but not 2.

是否有任何库可以同时执行这两项操作?

Are there any libraries that do both?

我已经为两者提交了错误,CXF 开发人员似乎坚持认为 2 不应该是一个功能 - 我不明白为什么.

I have submitted bugs for both and the CXF dev's seem adamant that 2 should not be a feature - I don't understand why.

提前致谢.

编辑 #1:

为了阐明我的意图,我想使用 REST 作为 SOA java 的支持传输机制.这种运输,IMO 应该是透明的;如果您有一个带注释的服务接口要遵守,那么客户端和服务器应该不需要了解彼此的任何信息.他们应该按照合同进行操作.此外,这个 API 应该是非侵入性的;示例:我发现使用 JAXB 注释业务对象\实体是侵入性的(如果我无法修改源怎么办?).

To clarify my intent, I would like to use REST as the backing transport mechanism for SOA java. This transport should, IMO be transparent; if you have an annotated service interface to adhere to, then the client and server should not need to know anything about each other. They should operate on the contract. Furthermore, this API should be non-intrusive; example: I find that annotating business Objects\Entities with JAXB IS intrusive (what if I can't modify the source?).

推荐答案

我认为我可以为您提供的最佳答案是选择最好、最活跃的堆栈并添加您的更改以使自己成为所需的支持.我认为没有哪个主要参与者可以满足您的需求.

I think the best answer I can provide you is pick the best, most active stack and add your changes to make yourself the needed support. I do not believe there is a major player that meets yours needs.

这篇关于java 休息客户端:jax-rs &自动类型映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 06:49
查看更多