After some code inspection, I found why the "org.apache.cxf.rs.databinding" OSGI property did not work for me. The version of DOSGI-CXF we are using does not support that property. Upgrading solved the problem.
-----Original Message----- From: Kampf, Eric Sent: Thursday, September 23, 2010 1:37 PM To: [email protected] Subject: RE: REST XML Structure Does not Match SOAP XML Sergey, Thank you for the response. Your question about data bindings has pointed me in the right direction I think. I read up on the different binding types. It appears that the Aegis binding is what we want our services to use. Our SOAP services are using "aegis". This is the default according to http://cxf.apache.org/distributed-osgi-reference.html. This same document indicates that REST can be configured with the same binding by setting the " org.apache.cxf.rs.databinding" OSGI property. Unfortunately, when I set this property to "aegis", it has no effect. The JAXB data binding is still being used. It appears that CXF is simply ignoring this property. Can anyone provide guidance on how else I might be able to configure this? Is this something that can be configured in a cxf.xml file? I am not having much luck finding this information in the CXF documentation. Thanks. -Eric -----Original Message----- From: Sergey Beryozkin [mailto:[email protected]] Sent: Wednesday, September 22, 2010 12:53 PM To: [email protected] Subject: Re: REST XML Structure Does not Match SOAP XML Hi On Wed, Sep 22, 2010 at 3:29 PM, Kampf, Eric <[email protected]> wrote: > Hello. > > I am working on an OSGI web application that uses CXF. We have a number of > existing service classes exposed via SOAP. We would now like to expose > REST versions of these services. When I built the first REST service, I > was surprised to see that the XML it produced did not match the XML of its > SOAP counterpart. Element name casing differed and collections were > represented differently. > > While it is not an absolute requirement that the XML structures match, it > is highly desirable. We have used the SOAP XML to predict the REST XML and > coded clients against this. > > One obvious solution would be to use JAXB annotations, but that is not an > allowable option at this time. > > What I am looking for is a way to configure CXF so that it uses the same > marshaling "mode" for both REST and SOAP. I have read the section of the > CXF manual on JAXB configuration, but it did not have the detail I was > looking for. My JAXB knowledge is a bit light. > > I have seen this behavior with CXF 2.2.6 and 2.2.10. > > Any guidance would be greatly appreciated. Thanks. > > Give us more information please. - I'm assuming you're using JAXB data binding for SOAP services ? Asking it because Aegis can probably deal with JAXB annotations too. - is it CXF HTTP Binding or JAXRS that you use ? If you use CXF JAXRS then you should be able to use the same JAXBDatabinding that you use for SOAP services, use jaxrs:dataBinding. http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_databinding/WEB-INF/beans.xml - you might want to try the legacy CXF Http Binding - it is probably capable of producing exactly the same xml ( http://cxf.apache.org/docs/http-binding.html). JAX-RS does not impose any restrictions on the way XML should look like - example, in case of JAXB it is whatever JAXB will produce will be sent over as is... - please post some sample SOAP response and expected non-SOAP response, sample service class (with a single service method) and sample bean which will have to be serialized. May be some trivial transformation (via configuring JAXRS JAXBElementProvider) will do...Specifically, see outTransformMap property : http://cxf.apache.org/docs/jax-rs.html#JAX-RS-CustomizingJAXBXMLandJSONinputandoutput For example, you may configure the provider to transform various local names as needed cheers, Sergey > -Eric >
