Feign Soap Exceptions
JAXB by default silently ignores errors.
Can you add this code to throw an exception if something goes wrong.
To SoapEncoder & SoapDecoder
unmarshaller.setEventHandler(
new ValidationEventHandler() {
@Override
public boolean handleEvent(ValidationEvent event ) {
throw new RuntimeException(event.getMessage(),
event.getLinkedException());
}
});
By javax.xml.bind.ValidationEventHandler#handleEvent contract you can simply return false and JAXB will throw an exception:
unmarshaller.setEventHandler(event -> false);
However I wouldn't add this sort of handling by default, as all of the written code already relies on the default JAXB behavior and instead provide means to customize feign.jaxb.JAXBContextFactory.Builder.
I agree with @virtual-machinist, this is something you'll have to provide to the SOAP encoder/decoder components. Those components should accept an external JAXBContext. If not, please open an enhancement issue/pr to do so.
@kdavisk6 I'm afraid it's not that simple and we have to modify feign.jaxb.JAXBContextFactory even if we allow external JAXBContext for SOAP encoders and decoders.
AFAIK you can only set the ValidationEventHandler when Marshaller and Unmarshaller instances are created, i.e. at some point in feign.jaxb.JAXBContextFactory#createUnmarshaller or feign.jaxb.JAXBContextFactory#createMarshaller.
In other words something like
public Builder withUnmarshallerValidationEventHandler(ValidationEventHandler handler) {
...
}
public Builder withMarshallerValidationEventHandler(ValidationEventHandler handler) {
...
}
is needed + modifications to the create factory methods.
If this is a reasonable proposal, I can make a branch + PR. :smiley:
@kdavisk6 I've created a PR (#2084) that hopefully addresses this issue.