-->

Which framework is better CXF or Spring-WS? [close

2019-01-12 17:21发布

问题:

I am in the process of researching/comparing CXF and Spring-WS for web services? I need to function both as a provider and a consumer of WS. In a nutshell, I have been told that Spring-WS is more configurable, but CXF is easier to get up and running. This question is subjective, but will help direct me in my research.

  • What experience do you have with either of these frameworks?
  • Have you run into any pitfalls with either framework?
  • Have you found any useful features provided by either that is possibly not provided by the other?

回答1:

I think the biggest difference is Spring-WS is only 'contract-first' whilst I believe CXF is normally 'contract-last'.

http://static.springsource.org/spring-ws/sites/1.5/reference/html/why-contract-first.html

Contract-last starts with Java code, so it is usually easier to get started with.

However, the WSDL it creates tends to be more fragile.



回答2:

About Apache CXF:

  • CXF supports several standards including SOAP, the WSI Basic Profile, WSDL, WS-Addressing, WS-Policy, WS-ReliableMessaging, WS-Security, WS-SecurityPolicy, and WS-SecureConversation.
  • Apache CXF offers both contract-last (starting with Java) and Contract-first (starting with the WSDL) approaches.
  • Apache CXF implements JAX-WS and JAX-RS.

About Spring WS:

  • Spring WS offers "only" contract-first, starting from an XSD Schema.
  • Spring WS supports SOAP, WS-Security, WS-Addressing.

So, at the end, I see Spring WS as a minimal web services framework but consider that it doesn't (in my opinion) have any advantages over Apache CXF (which integrates extremely well with Spring). Between both, I'd pick up Apache CXF.



回答3:

CXF does not, in any way, prevent you from starting with a contract (WSDL). I used both of these products to build a web service.

In CXF, I used Maven and the Maven plugin, calling the wsimport goal to generate the SEI (interface) which I then implemented. After implementing the interface to contain the actual service logic and configuring my bean implementation beans.xml, I then let Maven package it into a war file for deployment. The entire exercise could not have been easier.

I don't think Spring-WS offers any advantages that outweigh the lack of JAX-WS. CXF already lets you use Spring to wire up your beans and also has a full implementation of JAX-WS as well.



回答4:

We have an experience with CXF and it's predecessor XFire and I can recommend it as solid, quick (WS creating and executing) and reliable framework.

Regarding the issues that you can met with CXF see my post https://stackoverflow.com/questions/289977/recommended-framework-for-java-web-services#290205 And I agree with toolkit, that the biggest difference between frameworks are ideologically: what is the first code (i.e. interface) or contract (i.e. wsdl). See some details here:

  • Best Practices in Spring Web Services and Java
  • Spring WS Tutorial
  • What's New in Spring Web Services 1.5.


回答5:

Apache CXF:

Key Positives :

❶ Most widely used Web Services Standard Now; Improvement over AXIS2, which is now gradually being replaced by Apache CXF

❷ Intuitive & Easy to Use (less coding required as compared to AXIS2)

❸ Clean separation of front-ends, like JAX-WS, from the core code

❹ Fully compliant with JAX-WS, JAX-RS & others

❺ Best Performance across all available framework with minimum computation overhead

❻ Supports wide variety of front-end models

❼ Supports both JAX-WS & JAX-RS (for Restful Services)

❽ Supports JBI & SDO (not supported in AXIS2)

❾ Compatible with Spring Framework

Key Concerns:

❶ Does not support Orchestration & WS Transactions yet

❷ Does not support WSDL 2.0 yet

Spring WS:

Key Positives :

❶ Best in terms of supporting Contract-first Web Services Development Approach

❷ Enforces Standards & Best Practices by Framework Constraints (no way out of it & hence limitation as well)

❸ Supports Spring Annotations as well as JAX-WS

❹ Least code from developer’s perspective

❺ Best Aligned with Spring Technology Stack (also similar architectural stack as Spring MVC) including Spring Security

Key Concerns:

❶ Least number of WS-* Specifications supported (does not fully compliant with JAX-WS)

❷ Spring offers itself as standard & hence other Java-compliant frameworks support better standards support

❸ Only support Contract-first Web Services Development Model

Source : https://dzone.com/articles/apache-cxf-vs-apache-axis-vs



回答6:

Another option to consider in this comparison is Enunciate.

Especially if you like to start with Java first.



回答7:

Please take a look at a related post at : Building a web service with Spring-WS