It seems that in cxf, (I am working on 2.7.10 version), the jaxbValidationEventHandler is active for SOAP only and not for RESTful, is it right? I concluded this because when I forced to use JAXElement for unmarshalling in RESTful, my service can avoid unexpected elements without any exception. While in SOAP, I suppose that by default, all my classes are unmarshalled as JAXBElement, (because I don't have any JAXB annotation in my classes), but I still have to set the JAXB validation handler to false in order to avoid the thrown exception.
Am I right? Kind regards, Diana On 12 mars 2014, at 12:16, Sergey Beryozkin wrote: > The code shows that if this property is enabled then JAXB > ValidationEventHandler implementation is set... > > Cheers. Sergey > On 11/03/14 16:31, Diana ALLAM wrote: >> Thank you for your reply. >> I have a last question please. >> Could I have more implementation details about >> "set-jaxb-validation-event-handler", which is used in the beans.xml file in >> jaxws;properties? >> I know that JAXB allows adding handlers to marshaller, unmarshaller or >> validator. >> Does the "set-jaxb-validation-event-handler" correspond to a particular cxf >> Handler? If yes, which is exactly please? >> I have the cxf source code, and I see that >> "set-jaxb-validation-event-handler" is used in DataReaderImpl, but it's >> difficult to get how it works. >> >> Regards, >> Diana >> >> >> >> On 11 mars 2014, at 16:45, Sergey Beryozkin wrote: >> >>> 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 >>> >> > > > -- > Sergey Beryozkin > > Talend Community Coders > http://coders.talend.com/ > > Blog: http://sberyozkin.blogspot.com >
