I´m trying to use MTOM + XOP to return a byte[] in a Spring Web Service but when marshalling result it throws a SAXParseException with message:
cvc-type.3.1.2: Element 'dataHandler' is a simple type, so it must have no element information item [children].
It seems that after writing XOP tag, validator meet with it instead of the byte[] content that it expects and throws a SAXParseException with FATAL level that stops the process.
I´m using:
- JDK 1.7
- SAAJ 1.3
- SOAP 1.1
- Spring 4.1.4.RELEASE
- Spring WS 2.2.0.RELEASE
Thanks in advance
I´ve found two workarounds for my situation:
Not setting the xmlschema to marshaller.
Setting a
ValidationEventHandlerto marshaller that skips XOP failures.This is an example of setting a
ValidationEventHandlerto marshaller that skips XOP failures:Abstract superclass:
Concrete class for unmarshaller:
For marshaller I´m searching for the condition that identifies the case, because the
ValidationEventLocatoronly have the Object set and it could be whatever.org.springframework.oxm.jaxb.Jaxb2Marshallersubclass that activates MTOM and adds both event handlers: