You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "Kampf, Eric" <Er...@Kronos.com> on 2010/09/22 16:29:23 UTC

REST XML Structure Does not Match SOAP XML

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.

-Eric

Re: REST XML Structure Does not Match SOAP XML

Posted by Glen Mazza <gl...@gmail.com>.
I don't know REST much but I would think the JAX-RS XML structure would
follow the JAX-RS specification, just as the SOAP structure follows the
JAX-WS specification, and that the two XML structures would indeed be
different between the two specifications.  It would probably be best to code
your REST clients to the JAX-RS specification, helps keep things portable
anyway should you wish to move to another JAX-RS implementation.

Glen


Kampf, Eric 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.
> 
> -Eric
> 
> 

-- 
View this message in context: http://cxf.547215.n5.nabble.com/REST-XML-Structure-Does-not-Match-SOAP-XML-tp2849790p2849918.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: REST XML Structure Does not Match SOAP XML

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Eric - thanks for the confirmation. I did not know initially you were
using DOSGI.
You can also use "org.apache.cxf.rs.providers" property where you can list
class names of the providers. You can also register custom providers as OSGI
services

cheers, Sergey

On Fri, Sep 24, 2010 at 3:42 AM, Kampf, Eric <Er...@kronos.com> wrote:

> 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: users@cxf.apache.org
> 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:sberyozkin@gmail.com]
> Sent: Wednesday, September 22, 2010 12:53 PM
> To: users@cxf.apache.org
> Subject: Re: REST XML Structure Does not Match SOAP XML
>
> Hi
>
> On Wed, Sep 22, 2010 at 3:29 PM, Kampf, Eric <Er...@kronos.com>
> 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
> >
>

RE: REST XML Structure Does not Match SOAP XML

Posted by "Kampf, Eric" <Er...@Kronos.com>.
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: users@cxf.apache.org
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:sberyozkin@gmail.com] 
Sent: Wednesday, September 22, 2010 12:53 PM
To: users@cxf.apache.org
Subject: Re: REST XML Structure Does not Match SOAP XML

Hi

On Wed, Sep 22, 2010 at 3:29 PM, Kampf, Eric <Er...@kronos.com> 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
>

RE: REST XML Structure Does not Match SOAP XML

Posted by "Kampf, Eric" <Er...@Kronos.com>.
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:sberyozkin@gmail.com] 
Sent: Wednesday, September 22, 2010 12:53 PM
To: users@cxf.apache.org
Subject: Re: REST XML Structure Does not Match SOAP XML

Hi

On Wed, Sep 22, 2010 at 3:29 PM, Kampf, Eric <Er...@kronos.com> 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
>

Re: REST XML Structure Does not Match SOAP XML

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

On Wed, Sep 22, 2010 at 3:29 PM, Kampf, Eric <Er...@kronos.com> 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
>