Spring web services at a glance –
Spring web services is focused on creating contract-first document oriented web services. Spring web services, being a product of Spring, offer first class support of using Spring configurations and integrating with Spring framework.
Spring promotes contract-first development completely and provides an ability to plug-in various XML APIs (SAX, DOM, STAXM, XOM, JDOM..) to handle XML messages. Using Spring web services, you can always ensure the XML contract (xml schemas) is marshaled correctly into Java objects. Spring web services support JAXB 1 and 2, Castor, XMLBeans, JiBX, and XStream as part of its XML Marshalling support.
Spring web-service provides options to secure web services using Acegi security and provides ability to encrypt/decrypt messages and support for webservices security standards.
CXF at a glance
Apache CXF is an open source web service framework that provides an easy to use, standard-based programming model for developing web services. Web services can be implemented using different application protocols like SOAP, XML, JSON, RESTful HTTP, and support various transport protocols like HTTP or JMS (JavaMessage Service).
CXF supports both code-first and contract first development and provides first class support for using Spring configuration.CXF supports all of the widely used web service specifications.
Which one should I use ?
The choice of selecting a web services stack depends on multiple factors like standards compliance, ease of development , deployment options, unit testing options, integration with leading frameworks like Spring, flexibility and extensibility and so on.
In my view, the strict enforcement on using contract first development only with spring web services can become a bottle neck, depending on your requirements.
There might be scenarios where you would want to use code-first development and can easily generate contracts that way you intended. If you are aware of how Java objects are generated to XML and limitations associated with it, this would also help you to generate the right XML format. For instance, in CXF you can start with a XSD first approach as mentioned in my blog.
CXF provides support for code first and contract first development, and provides ability to plug-in various flexible binding mechanisms. Leaving the choice of code-first and contract first development to a user based on their requirements is a big plus.Using CXF, you could achieve what Spring web services offer today, although it doesn’t support the numerous XML API options and binding support offered by Spring web-services, but it should suffice for most of the requirements.The Object/XML Mapping that was initially provided by Spring Web Services project is now part of Spring 3.0 distribution. In my view this is a good move as you could deal with marshaling and un-marshaling xml payloads with various bindings like JAXB, Castor in Spring applications using the abstraction supported and probably might be able to plugin-in other web services stacks like CXF that want to leverage the Object/XML Mapping framework. But for Web Services support , leave it to CXF.
To know more about CXF framework , get a copy of my book- http://amzn.to/2ctLEmu