title: How to set the precedence for custom EndpointExceptionResolver in Spring web services
body: <p>I am trying to add custom error handling for Spring SOAP web services (version: 3.0.8) as per the steps in the below ticket.</p>
  <p><a href="https://stackoverflow.com/questions/53665662/how-to-return-custom-soap-error-from-spring-boot-endpoint-service">How to return custom SOAP Error from Spring Boot Endpoint Service?</a></p>
  <p>Added custom payload validator and EndpointExceptionResolver classes. However when the custom exception is thrown in Payload validator, it is being handled by default resolver (DetailSoapFaultResolver) instead of custom one.</p>
  <p>Though spring is recognising the new resolver it is given low precedence. How can I set the precedence so that Custom resolver is picked by the framework. Below are more details. Please help.</p>
  <p>Below is the order of resolvers at run time:</p>
  <pre><code>0 = SoapFaultAnnotationExceptionResolver
  1 = DetailSoapFaultResolver
  2 = CustomizedSoapFaultDefinitionExceptionResolver
  3 = SimpleSoapExceptionResolver
  </code></pre>
  <p><strong>Custom PayloadValidator:</strong></p>
  <pre><code>public class CustomValidatingInterceptor extends PayloadValidatingInterceptor {
  
    @SneakyThrows
    @Override
    protected boolean handleRequestValidationErrors(MessageContext messageContext, SAXParseException[] errors) {
  
      // if any validation errors, convert them to a string and throw on as Exception to be handled by CustomSoapErrorMessageDispatcherServlet
     String validationErrorsString = &quot;error message&quot;
  
        throw new CustomSoapValidationException(&quot;&lt;![CDATA[ --&quot; + validationErrorsString + &quot;]]&quot;);
      }
      return true;
    }
  </code></pre>
  <p><strong>Custom EndpointExceptionResolver:</strong></p>
  <pre><code>@Component
  public class CustomizedSoapFaultDefinitionExceptionResolver implements EndpointExceptionResolver {
      public boolean resolveException(MessageContext messageContext, Object endpoint, Exception ex) {
          if (ex instanceof CustomSoapValidationException) {
              throw (CustomSoapValidationException) ex;
          }
          return false;
      }
  }
  </code></pre>