Hello guys,

Since cxf 2.2.2 has been released (congratulations for your amazing work and
for your activity !), I would like to try the jaxrs XSLTJaxbProvider to
convert JAXB XML data in RDF.

My current server endpoint (only for XML result) :

        <jaxrs:server id="restServer" address="/">
                <jaxrs:serviceBeans>
                        <ref bean="productRestService" />
                </jaxrs:serviceBeans>
        </jaxrs:server>

The "productRestService" spring bean class : 

@Path("/prodservice")
public class ProductRestService {

        //domain service, with JPA stuff...
        private ProductServices productServices;

        @GET
        @Produces("application/xml")
        public ProductsDTO getAll() {
                return new ProductsDTO(productServices.getAllOrderByName());
        }
}

The "ProductsDTO" class (a custom collection wrapper) :

@XmlRootElement(name="list")
public class ProductsDTO {
        
        private List<ProductDTO> products;
        
        public ProductsDTO() {
                
        }
        
        public ProductsDTO(List<Product> list) {
                this.products = new ArrayList<ProductDTO>();
                
                for (Product product : list) {
                        products.add(new ProductDTO(product));
                }
        }
        
        @XmlElement(name="object")
        public List<ProductDTO> getProducts() {
                return products;
        }
}


And finally the XML result when calling "/prodservice" : 

<list>
        
                <categoryId>20</categoryId>
                <categoryLabel>Anti-dépresseurs</categoryLabel>
                <dangerous>true</dangerous>
                <description>test 1</description>
                <id>21</id>
                <name>Anti DEPRESS MAX2000+</name>
                <producer>PRODUCTEUR 1</producer>
                <reference>PROD1-ANTIDEPRESS</reference>
        
        
                ...
        
</list>


Now, i'd like to convert this in RDF format. I wrote an "rdf-stylesheet.xsl"
which works great with the produced XML result when tested in a standalone
program.

So, I try the new Provider to do the job : 

        <bean id="xsltProvider"
class="org.apache.cxf.jaxrs.provider.XSLTJaxbProvider">
                <property name="outMediaTemplates" ref="outMediaTemplates" />
        </bean>

        <util:map id="outMediaTemplates">
                <entry key="application/xml+rdf" 
value="classpath:rdf-stylesheet.xsl" />
        </util:map>

Then I updated my endpoint declaration with this provider :

        <jaxrs:server id="restServer" address="/">
                <jaxrs:serviceBeans>
                        <ref bean="productRestService" />
                </jaxrs:serviceBeans>
                <jaxrs:providers>
                        <ref bean="xsltProvider" />
                </jaxrs:providers>
        </jaxrs:server>

And finally I told my "ProductRestService" to produce xml+rdf  instead of
basic xml : 
        
        @GET
        @Produces("application/xml+rdf")
        public ProductsDTO getAll() {
                return new ProductsDTO(productServices.getAllOrderByName());
        }

when launching my /prodservice again, I got an ".No message body writer
found for response class : ProductsDTO." html error page.

It seems I am missing something here. Since XSLTJaxbProvider is a very new
feature, it isn't well documented yet.

I tried to inject an "outClassNames" list to my provider (with ProductsDTO
and ProductDTO), but it doesn't solve the problem.

Any idea ?

Thanks you in advance :-)


Gael
-- 
View this message in context: 
http://www.nabble.com/How-to-use-cxf-2.2.2-jaxrs-XSLTJaxbProvider-feature---tp23792102p23792102.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to