Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I read somewhere in the internet that JAX-WS is a SOAP implementation and JAX-RS a Rest implementation. Is this true? Are JAX-WS and JAX-RS implementations or specifications?
Thanks in advance.
They are specifications that define APIs.
JSR 224: Java API for XML-Based Web Services (JAX-WS) 2.0 http://jcp.org/en/jsr/detail?id=224
JSR 311: JAX-RS: The JavaTM API for RESTful Web Services http://jcp.org/en/jsr/detail?id=311
The APIs (interfaces, classes, and exceptions) they define require implementations.
The reference implementation (RI) for JAX-WS is included in Java SE. The JAX-WS RI is created as part of the Metro project (http://metro.java.net/). Metro includes enhancements and features beyond what the JAX-WS RI supports. In the SOAP world there are optional features like WS-Security that a web service stack can support. Metro supports those while the JAX-WS RI does not.
Since the JAX-WS is included in Java SE, yes you can make JAX-WS (SOAP) web services without a server. This is because there is a very basic HTTP server included in Java SE. You use the Endpont class to publish a service. This is really meant more for testing than anything else. The real reason JAX-WS is included in Java SE is to make it easier to be a SOAP service client. To truly run a JAX-WS web service you need a server such as GlassFish, JBoss, or WebLogic. There is some ability to add a JAX-WS implementation to Tomcat but only a true Java EE Application Server includes a complete implementation out of the box.
The reference implementation (RI) for JAX-RS is named Jersey (http://jersey.java.net/). JAX-RS is not included in Java SE. You must download an implementation. Once you download it you could use it without a server but again, it is really meant more for use in a server. One reason you download Jersey is to get the Jersey Client API to write clients (which is not a part of the current JAX-RS specification). Like with a JAX-WS implementation, you can add Jersey to Tomcat or a full Java EE Application Server will include a JAX-RS implementation.
JAX-WS and JAX-RS are both libraries (APIs) for doing communication in various ways in Java.
As you mentioned, JAX-WS is a library that can be used to do SOAP communication in Java, and JAX-RS lets you do REST communication in Java.
JAX-WS is a set of Java interfaces, classes, and annotations introduced in JSR 224:
The JAX-RPC 2.0 specification extends the existing JAX-RPC 1.0 specification with new features, including some or all of the following: direct support for JAXB 2.0-based data binding, support for the latest W3C and WS-I standards (e.g. SOAP 1.2, WSDL 1.2), standardized metadata for Java<->WSDL mapping, ease-of-development features, support for easier evolution of Web services, an improved handler framework, support for asynchronous RPC and non-HTTP transports.
It's an API and requires a runtime implementation, provided by, for example, Apache Axis2.
JAX-RS is an API for RESTful client/server communications introduced in JSR 311:
This API will enable developers to rapidly build Web applications in Java that are characteristic of the best designed parts of the Web. This JSR will develop an API for providing REST(Representational State Transfer - See reference to Roy Fielding's dissertation in section 3.1) support in the Java Platform. Lightweight, RESTful approaches are emerging as a popular alternative to SOAP-based technologies for deployment of services on the internet. Currently, building RESTful Web services using the Java Platform is significantly more complex than building SOAP-based services and requires using low-level APIs like Servlets or the dynamic JAX-WS APIs. Correct implementation requires a high level of HTTP knowledge on the developer's part.
Again, it requires an implementation, provided by, for example, Jersey.
Related
What is the most common and standardized way to create a ReST Java Web service ?
For now, I just use a Perl program to invoke my Java application but I think it's not the most efficient way.
Use JAX-RS for creating RESTful webservices as it is officially part of java EE 6 specification, previously JAX-RPC was used which has now been replaced by JAX-RS, wikipedia states:
JAX-RS: Java API for RESTful Web Services (JAX-RS) is a Java programming language API that provides support in creating web services according to the Representational State Transfer (REST) architectural pattern.[1] JAX-RS uses annotations, introduced in Java SE 5, to simplify the development and deployment of web service clients and endpoints.
From version 1.1 on, JAX-RS is an official part of Java EE 6
I really cant understand what really is jersey..
What I know is that Jax-RS is an API for building REST web services, and jersey?
I got some information and all say the same: "jersey is an implementation of Jax-RS". But what it means?
If jax-rs is an API, why we need jersey for create a rest web service? Is jersey a couple of more libs to aim with jax-rs? if yes, jax-rs is an incomplete API?
JAX-RS is an specification (just a definition) and Jersey is a JAX-RS implementation.
Straight from the jersey site
Jersey framework is more than the JAX-RS Reference Implementation.
Jersey provides its own API that extend the JAX-RS toolkit with
additional features and utilities to further simplify RESTful service
and client development. Jersey also exposes numerous extension SPIs so
that developers may extend Jersey to best suit their needs.
JAX-RS is an specification and Jersey is a JAX-RS implementation.- True
This can be understood relating it to OOPS principles JAX-RS is an Interface and Jersey is a class implementing that interface.
These Specification creates a STANDARD for developing and using the web services.
There are other JAX-RS implementations too like wink, RestEasy.
JAX-RS is a specification which specifies how can we implement the web services,that what would be input type, input format, output type, its format, its configuration etc.Its Just a type declaration and its implementation are these libraries, Jersey, wink RestEasy etc.
Further, Java also have specification like JPA(Java Persistence API) and like mentioned above there is Hibernate which is an implementation of JPA.
JAX-RS is an specification (just a definition) and Jersey is a JAX-RS implementation. Jersey framework is more than the JAX-RS Reference Implementation. Jersey provides its own API that extend the JAX-RS toolkit with additional features and utilities to further simplify RESTful service and client development.
Using JAX-RS alone can not implement REST, need to register Jersey as the servlet dispatcher for REST requests on web.xml
A standard and portable JAX-RS API has been designed. Jersey RESTful Web Services framework is open source, production quality, framework for developing RESTful Web Services in Java that provides support for JAX-RS APIs and serves as a JAX-RS (JSR 311 & JSR 339) Reference Implementation.
Jersey framework is more than the JAX-RS Reference Implementation. Jersey provides it’s own API that extend the JAX-RS toolkit with additional features and utilities to further simplify RESTful service and client development. Source
For more
Restlet and Jersey are two of the most popular implementation of JAX-RS used for developing RESTful web services in Java ecosystem but there are a couple of other implementation also exist e.g. Apache Wink, Apache CXF, and JBoss RESTEasy.
Source
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 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.
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.