CXF supports JAX-RS (JSR-311), Java API for RESTful Web Services. JAX-RS provides a more standard way to build RESTful services in Java. CXF 2.2-SNAPSHOT supports the final version of JSR-311 API while CXF 2.1.x currently supports only 0.8 version of JSR-311 API . JAX-RS related demos are located under samples/jax_rs directory (CXF 2.2 and CXF 2.1 only).
This documentation will refer to JSR-311 API 1.0 only 0.8 version of JSR-311 API .
JAX-RS related demos are located under samples/jax_rs directory (CXF 2.2 and CXF 2.1 only).
This documentation will refer to JSR-311 API 1.0 .
Migrating from 0.8 to 1.0
The following major changes in 1.0 will most likely affect users migrating from 0.8
- @ProduceMime and @ConsumeMime have been replaced with @Produces and @Consumes respectively
- HttpHeaders has had some of its methods returning a string representation of Locale updated to return Locale instead
As JAX-RS API 1.0 is currently supported in CXF 2.2-SNAPSHOT, it's also worth noting of the following changes in dependencies :
- Spring version have changed from 2.0.8 in 2.1.x to 2.5.6
- jaxb-api version has changed to javax.xml.bind/jaxb-api/2.1
- jaxb-impl version has changed to com.sun.xml.bind/jaxb-impl/2.1.7
Additionally, org.apache.cxf/cxf-rt-databinding-aegis/2.2-SNAPSHOT compile-time dependency has been added
Maven dependencies
The following 3rd-party dependencies are used when building CXF JAX-RS implementation :
1. javax.ws.rs/jsr311-api/0.8 -> javax.ws.rs/jsr311-api/1.0
available from either
Code Block | ||||
---|---|---|---|---|
| ||||
<repository>
<id>java.net.2</id>
<name>Java Net 2 Repository</name>
<url>http://download.java.net/maven/2</url>
</repository>
|
or from a central maven repository
2. org.apache.abdera groupId : abdera-core, abdera-parser and abdera-extension-json artifacts, version 0.4.0-incubating. Available from
Code Block | ||||
---|---|---|---|---|
| ||||
<repository>
<id>apache.incubating</id>
<name>Apache Incubating Repository</name>
<url>http://people.apache.org/repo/m2-incubating-repository</url>
</repository>
|
3. org.springframework/spring-core/2.5.6
4. org.codehaus.jettison/jettison/1.0.1
5. org.apache.xmlbeans/xmlbeans/2.3.0 - compile time
Please check the pom.xml for the list of cxf components used by the JAX-RS implementation
CXF JAX-RS bundle
A standalone JAX-RS bundle is now available which may be of interest to users doing JAX-RS work only. Some updates to the pom is needed to ensure some of the artifacts pulled in as part of a dependency on cxf-api are actually omitted - contributions are welcome.
Understanding the basics
...
Code Block | ||||
---|---|---|---|---|
| ||||
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxrs="http://cxf.apache.org/jaxrs" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd"> <import resource="classpath:META-INF/cxf/cxf.xml" /> <import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" /> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> <jaxrs:server id="customerService" address="/"> <jaxrs:serviceBeans> <ref bean="customerServicecustomerBean" /> </jaxrs:serviceBeans> </jaxrs:server> <bean id="customerServicecustomerBean" class="demo.jaxrs.server.CustomerService" /> </beans> |
...