Spring 3.0 JAX-WS and or vs. Apache CXF - java

Spring 3.0.1 has solid JAX-WS web services support. At the same time, I see that many articles refer to Apache CXF as a great web services framework.
If I work in the Spring/Hibernate world and want to expose the high-performing web services to the front end, should I consider utilizing Apache CXF? Is there any advantage to adding this additional framework to the mix?

The two are not mutually exclusive. Apache CXF is fully JAX-WS compliant.
Remember, JAX-WS is just a specification. Spring talks ato that spec'd API, and doesn't much care which implementation you use. Java6 ships with an internal JAX-WS implementation (Metro, or part of it), and CXF is merely an alternative implementation.
CXF is probably a bit more capable than the JAX-WS that ships with Java6, but unless there's something specific that you need that Java6 doesn't provide, I'm not sure it's worth the bother.
As for Spring and JAX-WS, Spring just makes it a little bit easier to use.

Related

Difference between Application servers and standalone frameworks

I would like you guys to give me some feedback, on my understanding about the
difference between Application Servers such as JBoss and frameworks such as Axis and CXF.
CXF is a standalone, web-app based framework that
implements JAX-RS, JAX-WS API wich, in turn, are part of the
larger API set of JEE.
Being a web-app based implementation, it
can only be used to host "SOAP on HTTP" services even if the
standard JAX-WS defines other possible channels for SOAP
messages,such as SMTP.
Application servers,such as JBOSS, instead implement JAX-WS as well as all the other JEE APIs in a more "native" and direct way, so,for example, they can be used to host also SOAP on SMTP services.
Both AS and standalone frameworks such as CXF and AXIS make
extensive use of Inversion of control.
Application Servers, such as Jboss, can be thought as composed by a
set of frameworks that implement all the JEE stack API.
Please take some time to correct/enhance the above statements.
Thanks

Definition of JAX-WS and JAX-RS [closed]

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.

Java framework to use for JSON based web service

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

Which Java Web Service Framework do you prefer?

I am gonna implement web service in Java but before implementation I will decide which framework I should use. Simplicity and running on JBoss 4.2.3 Platform are the requirements.
What is your suggestions?
Instead of using an additional technology stack component, why not use the #WebService annotation introduced in EJB3. JBoss 4.2.3 supports EJB3
Two examples
Using EJB3 Web Services guarantees that you web services will run on any Java EE compliant server without any modifications to the server.
Since JBoss provides JavaEE features, you can simply take a look at JAX-WS, annotate your EJBs, and let JBoss handle everything from there.
Otherwise you can look at Apache CXF and for JBoss + CXF see here
Axis2 on Tomcat 6
JAX-WS on Tomcat 6
Quick, Fast and Easy

Implementing RESTful web service

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.

Categories