cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Beryozkin <sberyoz...@gmail.com>
Subject Re: JAX-RS: marshalling/unmarshalling between cxf 2.5 and cxf 2.7
Date Thu, 13 Jun 2013 15:34:23 GMT
Hi
On 13/06/13 15:22, allam wrote:
> Hello,
>
> I have a restful service which implements the following interface:
> @Path("/service/")
> public interface ServiceInterface {
>
>      @POST
>      @Path("/resources/")
>      public void op(Resource1 r);
>
> }
>
> and I have two classes Resource1 and Resource2, such that Resource2 extends
> Resource1.
> (I am not using @XmlSeeAlso annotation in Resource1 class to bind on
> Resource2 class).
> I would like to call the service method op, using an instance of Resource2.
>
> Before, by using CXF 2.5, the Resource2 instance is marshalled to the
> following XML :
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <resource2>
>     <attr1>default</attr1>
>     <attr2>0</attr2>
> </resource2>
>
> and an exception is thrown at reception because the expected root element is
> "resource1" not "resource2".
That is correct I guess
>
> While by using CXF 2.7, the Resource2 instance is marshalled to the
> following XML:
> <resource1>
>     <attr1>default</attr1>
> </resource1>
>
> And there isn't any exception at reception.
> That means, in CXF 2.5, the marshalling type was the dynamic type, while in
> the cxf 2.7 version, the marshalling type is the static type.
> What does make this change between the two versions?
> and for which reason this modification was done between the two versions?
In CXF 2.5.x the actual object instance class was reported to the 
providers, in CXF 2.7.x - the class of the method parameter, which is 
correct.
The fact that no exception is reported is good. I think you need now to 
use XmlSeeAlso or may be configure JAXBElementProvider to report 
xsi:type if needed, etc, and on the client side, check please

http://cxf.apache.org/docs/jax-rs-data-bindings.html#JAX-RSDataBindings-CommonJAXBandJSONconfiguration

Cheers, Sergey

>
>
> Regards,
>
> Diana
>
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/JAX-RS-marshalling-unmarshalling-between-cxf-2-5-and-cxf-2-7-tp5729200.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Mime
View raw message