You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "Muller, Anthony" <an...@sap.com> on 2012/09/20 13:13:15 UTC
JAX-RS, JAXB and streaming
Hello Sergey,
When JAXB is used for data binding, is there a way to stream the output instead of waiting to build the whole object structure to return?
This will be very useful when we have large object tree to build!
Thanks,
Anthony
Re: JAX-RS, JAXB and streaming
Posted by Daniel Kulp <dk...@apache.org>.
On Sep 20, 2012, at 7:13 AM, "Muller, Anthony" <an...@sap.com> wrote:
> Hello Sergey,
>
> When JAXB is used for data binding, is there a way to stream the output instead of waiting to build the whole object structure to return?
The "normal" way to do this with JAXB is to have the objects themselves return more "dynamic" objects instead of static. If you have the @XmlAccessorType set to XmlAccessType.PROPERTY and the getter/setters are annotated instead of the fields, JAXB will call the getter/setters during marshaling. Those getters and setters can dynamically build themselves up rather than returning actual field members.
The List returns can even be smarter. JAXB just uses the iterator from the list to write out the list. Thus, the List can be completely dynamic and for each call of "next" on the iterator, create a new object and return it.
> This will be very useful when we have large object tree to build!
It's a bit tricky to setup, but it can work fairly well.
--
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com
Re: JAX-RS, JAXB and streaming
Posted by "tms.polgar" <tm...@gmail.com>.
Thank you guys,
I just found the solution:
You need to set the "set-jaxb-validation-event-handler" property to true
when you create your client proxy:
JaxWsProxyFactoryBean proxyFactoryBean = new JaxWsProxyFactoryBean();
proxyFactoryBean.setAddress(endpointUrl);
Map<String, Object> propertiesMap = new HashMap<String, Object>();
propertiesMap.put("set-jaxb-validation-event-handler", "false");
proxyFactoryBean.setProperties(propertiesMap);
MyService service = proxyFactoryBean.create(MyService .class);
Regards,
Tamas
--
View this message in context: http://cxf.547215.n5.nabble.com/Tolerate-extra-fields-in-response-tp5714284p5714293.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: JAX-RS, JAXB and streaming
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 20/09/12 12:13, Muller, Anthony wrote:
> Hello Sergey,
>
> When JAXB is used for data binding, is there a way to stream the output instead of waiting to build the whole object structure to return?
>
> This will be very useful when we have large object tree to build!
>
JAX-RS offers StreamingOutput interface and the implementations can
write to and flush the output stream immediately after a portion of XML
has been written to it. However I guess it also implies that one has to
do more than only delegate to JAXB to marshall say "MyBigDataModel" but
perhaps wrap some parts of the mode into JAXP Source, etc.
One other thing I know is that if you wrap a model into JAXP Source on
the output then by default CXF StaxSource will be used to push the data out.
I'm not sure how else CXF can specifically help with enabling the
JAXB-based streaming on the output.
Dan, do you know of any other JAXB or CXF techniques that can help ?
Cheers, Sergey
> Thanks,
> Anthony