Hello,
I have a problem setting a custom validation event handler in cxf for a
Marshaller.
I can only setup the custom handler when reading a XML, not writing it.
(I need to have some logging when the marshalling does not behave as
expected, for example when marshalling a datetime that has undefined time,
jaxb output nothing, but I cannot see anything in the logs)
I tried this with various cxf versions (2.4.4 and 2.5.0).
I setup the handler in the spring configuration file:
<jaxws:endpoint id="myEndpoint"
implementor="#beanService" address="/service" >
<jaxws:properties>
<entry key="jaxb-validation-event-handler"
value-ref="loggingValidationEventHandler" />
</jaxws:properties>
</jaxws:endpoint>
<bean id="loggingValidationEventHandler"
class="test.LoggingValidationEventHandler" />
>From what I can see debugging, there is a difference in the way the
Marshaller is set in DataReaderImpl and DataWriterImpl:
In the DataReaderImpl, in the setProperty method, I see code that reads the
properties:
veventHandler =
(ValidationEventHandler)m.getContextualProperty("jaxb-validation-event-handler");
if (veventHandler == null) {
veventHandler = databinding.getValidationEventHandler();
}
setEventHandler = MessageUtils.getContextualBoolean(m,
"set-jaxb-validation-event-handler", true);
and in createUnmarshaller there is something to set the custom handler:
if (setEventHandler) {
um.setEventHandler(new WSUIDValidationHandler(veventHandler));
}
But in DataWriterImpl the properties are not read, and in createMarshaller
I only see:
if (databinding.getValidationEventHandler() != null) {
marshaller.setEventHandler(databinding.getValidationEventHandler());
}
I could not find a way to set the validation event handler in databinding.
How can I set the custom ValidationHandler in the Marshaller ?
Thanks & Regards,
Vincent