Praveen
Praveen

Reputation: 1

Apache CXF stop transaction propogation for server side XSD validation errors

We have CXF SOAP over JMS service and we have enabled the XSD validation using schema-validation-enabled property. With this configuration, for all types of errors transaction rollback is happening. We want to stop rollback for XSD validation error and allow rollback for runtime errors.

We have added the onException(ValidationException.class).handled(true) but for SOAP over JMS, when validation exception happens, below code is not executed and rollback is called before itself.

is there a way in Apache CXF, we can control the rollback based on exception type - not to have rollback for xml validation type of exception?

Upvotes: 0

Views: 119

Answers (1)

burki
burki

Reputation: 7015

Your question contains quite little information.

But, as you wrote, you have enabled the schema-validation-enabled property of CXF. Therefore, if a request is not schema valid, the framework stops it. The request does not reach your code. I guess the client receives a Soap Fault from CXF.

In CXF you can customize a lot! You could even write your own JAXB validator that replaces or extends the one of CXF and handles invalid requests as you want it to. See for a simple example this question. You can then configure it like this.

<jaxws:properties>
        <entry key="schema-validation-enabled" value="true" />
        <entry key="jaxb-validation-event-handler">
            <bean class="com.your.package.MyCustomHandler"></bean>
        </entry>
</jaxws:properties>

A lot of CXF customization is also done with Interceptors. But I don't know if it works for validation too.

And of course you could also disable schema validation in CXF and validate with Camel Validator. But then you have to take care about invalid requests that cannot be transformed to objects.

Upvotes: 0

Related Questions