用于基于 JSON 的 Web 服务的 Java 框架
我正在编写一个基于 JSON 的 Web 服务。该服务将接受两种类型的请求:命令(例如createOrder)和查询(例如getOrders)。每个请求都需要发送用户凭据(用户名/密码)以进行身份验证(可能在 HTTP 标头中)。该服务需要用Java 实现。
对于这个用例,您会推荐哪些框架?我想到的最基本的堆栈是由 Jackson 等 JSON 框架支持的 servlet。您还会推荐其他框架吗?为什么?没有必要或不希望使服务成为 RESTful,但是与 Java EE 6 或 Spring 的顺利集成将是一个优势。
预先感谢您的宝贵时间。
I am in the process of writing a JSON based web service. The service will accept two types of requests: commands (e.g. createOrder) and queries (e.g. getOrders). Each request needs to send user credentials (username/password) for authentication (perhaps in HTTP headers). The service needs to be implemented in Java.
Which frameworks would you recommend for this use case? The very basic stack that I am thinking of is servlets backed by a JSON framework like Jackson. Are they any other frameworks that you would recommend and why? There is no need or desire to make the service RESTful, however smooth integration with Java EE 6 or Spring would be a plus.
Thanks in advance for your time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
那么我可以让您对RESTful Web Services(即JAX-RS API)?实现 JAX-RS 的库是 Jersey、Apache CXF,适合允许 JSON Web 服务。
相关的 StackOverflow Post 显示了符合 JAX-RS 的 REST 客户端。
Can I then interest you in RESTful Web Services (which is a JAX-RS API)? A library that implements JAX-RS is Jersey, Apache CXF, which is suited to allow JSON Web Service.
A related StackOverflow Post which shows REST clients that conforms to JAX-RS.
您应该查看 spring mvc 并阅读 < a href="http://blog.springsource.com/2009/03/08/rest-in-spring-3-mvc/" rel="nofollow">这篇博文,其中介绍了如何使用 spring mvc安宁的WS。
You should take a look at spring mvc and read this blog post which cover using spring mvc for restful WS.
玩吧!框架绝对适合您的需求。它不是基于 servlet,但满足您的所有要求。另外,使用 Play 进行开发的速度非常快,您可以立即建立并运行原型。
Play! Framework would definitely fit your bill. It is not servlet-based but fulfills all of your requirements. Plus development with Play is very fast, you can get a prototype up and running in no time.
我个人使用 Apache CXF、JAX-RS 和 jackson 库。它们很容易实现,并且集成也非常容易。 JAX-RS 是一个 java 标准,Jackson 库速度很快并且可以处理循环引用,Apache CXF 只需要几行配置即可设置并开始运行。大胆试试吧!
I personally use Apache CXF, with JAX-RS and jackson libraries. They are easy to implement and integration is dead easy. JAX-RS is a java standard, Jackson library is fast and handles circular references and Apache CXF needs only a couple of lines of configuration to setup and start running. Go for it!
Apache 的开源服务框架
-CXF 旨在提供可插拔的该体系结构不仅支持 XML,还支持非 XML 类型绑定(例如 JSON 和 CORBA)与任何类型的传输相结合。
-Java EE 集成:在 Java EE 应用服务器(例如 Apache Geronimo、JOnAS、Redhat JBoss、OC4J、Oracle WebLogic 和 IBM WebSphere)中部署服务
-独立的Java客户端/服务器
An Open-Source Services Framework From Apache
-CXF has been designed to provide a pluggable architecture that supports not only XML but also non-XML type bindings, such as JSON and CORBA, in combination with any type of transport.
-Java EE integration: deploy services in Java EE application servers such as Apache Geronimo, JOnAS, Redhat JBoss, OC4J, Oracle WebLogic, and IBM WebSphere
-Standalone Java client/server