You can use StaxTransformFeature to drop unexpected elements (such as Description) or XSLTTransformFeature, follow the links at the end of

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

Cheers, Sergey


On 11/03/14 13:23, allam-di14 wrote:
I have the following operation op provided by a server:
void op(A a)

Such that A has two attributes "key" and "value".

I would like to invoke this operation using the following payload:
Payload:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";>
        <soap:Body>
                <ns3:op xmlns:ns2="http://test/"; xmlns:ns3="http://server/";>
                        <arg0>
                                <key>1</key>
                                <value>Diana</value>
                                <description>PHD</description>
                        </arg0>
                </ns3:op>
        </soap:Body>
</soap:Envelope>

This payload has an additional element "description", at unmarshalling, the
following exception is thrown:
org.apache.cxf.interceptor.Fault: Unmarshalling Error: unexpected element
(uri:"", local:"description"). Expected elements are <{}value>,<{}key>
        at
org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:881)
        at
org.apache.cxf.jaxb.JAXBEncoderDecoder.unmarshall(JAXBEncoderDecoder.java:702)
...

This exception is due to JAXB validation Event Handler.
I can get rid of it with the following spring configuration :
<jaxws:properties>
        <entry key="schema-validation-enabled" value="false" />       
        <entry key="set-jaxb-validation-event-handler" value="false" />
</jaxws:properties>

But disabling the JAXB validator is not a good thing.
I would like to do it better by unmarshalling my payload as JAXBElement,
because it will ignore the additional XML elements.

Regards,
Diana




--
View this message in context: 
http://cxf.547215.n5.nabble.com/XmlRootElement-with-jax-rs-jax-ws-tp566400p5741094.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

Reply via email to