I’m running into a problem with JAXB unmarshalling that I have no clue how to solve. It relates to unmarshalling SOAP headers. In my SOAPHandler, I have a SOAPMessageContext object which has a getHeaders() method. This method takes in a QName and a JAXBContext as parameters and will automatically unmarshal any matching headers.
My problem is that I am passing the appropriate headers but the unmarshalled object is returned empty (ie: all the fields are null).
I am a little stumped as I cannot control any of the unmarshalling; I cannot set validators (and see if there is a schema problem) or anything else as everything is happening in a “black box”. All I can pass is the JAXBContext to the method.
Is there anything I can do to figure out why the unmarshalling is failing even though there is no exception being thrown?
Thanks,
Eric
Ok – so after a bunch of head scratching, I realized that I could try and replicate the getHeaders() method myself and enable validation/etc on the unmarshaller to find out where the problem was.
I ended up extracting the header as an xml node using the following:
In my xmlUtil class, I can create my own JAXB unmarshaller and enable schema validation and not rely only on the getHeaders() method to do everything magically for me.
Hope this can be helpful for someone else.
Thanks,
Eric