I have a requirement to create RESTful web service.
I have narrowed down on 'Restlet' for the web service implementation.
Can someone tell me the clear pro's and con's of using Restlet and if there are any better alternatives.
thanks in advance
Restlet has an extensive list of extensions for Spring, WADL, XML, JSON as well and many more, including an extension for JAX-RS API.
It is also the sole framework available in six consistent editions:
Java SE
Java EE
Google Web Toolkit
Google AppEngine
Android
OSGi Environments
Its main benefits are:
fully symmetric client and server API when JAX-RS was designed for server-side processing
connectors for other protocols than HTTP (mapping to HTTP semantics) when JAX-RS is HTTP only
much broader feature scope including full URI routing control via the Restlet API (but can integrate with Servlet if needed)
full provision for NIO support
The JAX-RS API can be a good choice if you are restricted to JCP approved APIs (then don't use Spring or any extension of the JAX-RS projects like Jersey and RESTeasy!), but otherwise Restlet is the most mature framework (initially released in 2005) and will give you, in its 2.0 version, all the benefits of annotations combined with a powerful and extensible class-oriented framework.
For a longer list of features, please check this page.
Best regards,
Jerome Louvel
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
For a comparison of JAX-RS frameworks see JAX-RS Frameworks
Jersey API can be used to implement RESTful Web services.
http://jersey.java.net/
Other than RESTful Web services, Jersey also provide many other features.
Some more useful links regarding available REST frameworks and their comparisons:
A Comparison of JAX-RS Implementations
rest-introduction
tilkov-rest-doubts
Rest anti-patterns
JAX-RS Vendor Comparisons - Part I
Apache Cocoon is a very good solution to implementing a RESTfull Web Services.
Related
I have a Java Restful application that uses Jersey for the APIs implementation and that uses Spring for DI. I'm now trying to integrate HDIV for security.
However the official documentation has examples for the integration with Spring MVC, but not Restful Jersey applications.
Documentation here:
https://hdivsecurity.com/technical-documentation/doc.html
I read online that it's possible to integrate HDIV with REST, but I cannot exactly figure out how this is done, as I cannot find examples.
Does anyone know how this is done?
As you said Hdiv can be integrated with REST APIs, particularly RESTFul APIs that implements the whole REST specification, including Hypermedia or HATEOAS level (level 3 within Richarson model)
This REST support is included inside Hdiv Enterprise edition and that's why is not included in the link related to the technical documentation provided by you. The security level offered in that integration is exactly the same that we have been offering till now for server side MVC applications. It means that Hdiv can automate the protection against OWASP top 10 web risks in REST based applications .
Regarding JAX-RS support it can be possible if you are using the new hypermedia support included within JAX-RS 2/Java EE 7.
If you need more detail about the Hdiv support for RESTFul APIs you can review the slides presented in the last Spring I/O conference.
If you want to test within your project this support please contact using Hdiv support web form within hdivsecurity.com web site.
Regards,
Roberto Velasco
JAX-RS is a specification that helps you develop restful web services in Java.
But JAX-RS seem to be requiring a servlet container like "Tomcat"or "Jetty".
Managing container in a clustered mode is painful and more operations heavy.
Is there way to start JAX-RS service like a normal Java program/application ?
I want to use JAX-RS implementation but I don't want to follow typical"deploy" cycle.
JAX-RS is strongly linked to HTTP, hence most implementations (eg Jersey, Apache CXF) run in a servlet, which in turn runs in a container such as Tomcat or Jetty. I guess you could develop your own standalone JAX-RS implementation, but you'd end up reinventing the wheel as you'd be forced to implement most aspects of a web server.
Your worries about clustering also seem unfounded. Clustering Tomcat is simple, it is a very common thing to do and there's plenty of information available on the subject. It seems like clustering a custom implementation would actually be a much harder job.
I am new to web services and below I am sharing my understanding so far by reading on net:
Apache Axis and Apache CXF - are web services frameworks used to develop Java web services.
JAX-RS - Java API to develop Restful web services.
JAX-WS - Java API to develop SOAP web services.
Is the above correct? Or if you want to add something to it.
In my project, I am going to use web services with Spring framework.I am told that project will have both SOAP and RESTful web services.I am very much new to this.
Can somebody please guide me in this regard by sharing some valuable information or any good link which will make me understand better?
Your statements are correct, but it's not clear whether you've understood one crucial fact: CXF and Axis are both implementations of the JAX-WS standard. CXF additionally implements JAX-RS, and there are some libraries that only implement JAX-RS, such as Jersey (Oracle's reference implementation) and RESTEasy from JBoss.
For your project, the big question is whether you will only consume those webservices, or also publish them. If you need to publish a webservice, you'll have to include the entire implementation library and learn to use it. If you only consume the services, you'll just need some generated client and data binding classes.
Another question is whether your RESTful services will talk XML or JSON (SOAP always uses XML), as you'll need a parser or binding framework for JSON (JAX-B for XML is included in recent JDKs).
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.
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.
You should take a look at spring mvc and read this blog post which cover using spring mvc for restful WS.
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.
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!
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
I am not much aware about the details as to which web servers support Web services written in Java.
Would Like to know the following three things:
1) What is required to have support for Web Services : Only Servlet Container or An Application Server + Web container?
2) Would like to know that do all Web Server supporting web development in Java support Web Services?
3) How to identify whether a particular server supports Web Services or not?
Thanking you in advance.
Your question is somewhat unclear. The term web service is applied to anything from a REST style API to SOAP based services to JSON based, etc etc. Wikipedia says an equivalent is a Web API, and an API can be pretty much anything.
So to answer your question. A servlet container is enough to support most common types of web services, it doesn't require an application server. Take a look at Apache CXF, which is a framework catering for a lot of web services styles (notably SOAP and REST).
Apache CXF is a rather large framework, and can take some time to get your head around. If you need something simpler, you may be better off looking at some object serialization frameworks and implement the servlets yourself (this is what I do mostly). To serialize to XML, use out-of-the box Java JAXB annotations. To serialize to JSON, use Jackson.
Assuming you're talking about SOAP WS-* web services via JAX-WS.
Java EE 5+ stipulates support for JAX-WS compatible web services within the container, both at the Web App level, and at the EJB level. So, any full boat, modern, App Server will have JAX-WS support built in.
Servlet 2.x and 3.0 do not have a requirement to support JAX-WS at the container level, but all of the major implementation of JAX-WS can be deployed within a WAR in a modern Servlet container (like Tomcat).
Java EE 6 offers a Web Profile, but the Web Profile does not include JAX-WS. Java EE 6 Full Profile includes both JAX-WS (SOAP, WS-* web services), and JAX-RS (for HTTP and more RESTful web services).
So.
If you bundle your own implementation, all of the containers should accommodate you. If you want it built it to the container, you'll need a full Java EE 5 or Java EE 6 App Server.