Hi
On 23/05/13 22:02, Greg Barker wrote:
Hello -

I'm using the Apache CXF WebClient for a project, and the REST API I am
interacting with has a requirement that XML elements are sent in a specific
order, and "correct" order can change depending on certain settings that
are not known at compile time.

I've found that the XmlType.propOrder annotation allows me to specify the
order in which I want the XML elements to appear at compile time. This
works great. The problem is that I need to be able to change this order at
runtime, and I cannot figure out a way to do that without resorting to
ugly/hacky solutions that modify the annotation at runtime.

Is there an easy way to specify XML element order dynamically at runtime?

Try Transformation feature:

http://cxf.apache.org/docs/transformationfeature.html

Use outDropElements and outAppendElements properties.

Suppose you have the following produced by default:
<request>
  <a/>
  <b/>
</request>

if needed, you can get <a/> dropped with outDropElements and then added immediately after <b/> with outAppendElements.

If that has to be set up dynamically then add the feature or its interceptors from the code, similarly to
http://cxf.apache.org/docs/transformationfeature.html#TransformationFeature-Configuringthefeaturefromthecode

HTH, Sergey

Thanks!
Greg


Reply via email to