Adding detail in a WS SoapFault : my custom ExceptionResolver is not used

后端 未结 2 954
囚心锁ツ
囚心锁ツ 2020-12-10 19:29

I\'m building a web service using Spring Boot (1.2.4.RELEASE) and I\'m quite new to this framework. Especially, I\'m trying to customize the SoapFault content when a

2条回答
  •  天命终不由人
    2020-12-10 20:26

    As usual, I solve my problem an hour after posting it online. I should have done it earlier !

    The bean name/id I tried to override was not right. After scanning a huge amount of org.springframework.beans debug logs, I found that the right bean name is soapFaultAnnotationExceptionResolver.

    I also managed to convert the configuration in Java form:

    package foo.bar.ws;
    
    // Skipping imports...
    
    /**
     * WS configuration and WSDL definition
     */
    @EnableWs
    @Configuration
    public class WebServiceConfig extends WsConfigurerAdapter {
    
        public final static Logger logger = Logger.getLogger( WebServiceConfig.class );
    
        // Skipping other bean declarations...
    
        @Bean(name = "soapFaultAnnotationExceptionResolver")
        public DetailSoapFaultDefinitionExceptionResolver exceptionResolver( ApplicationContext applicationContext ){
            DetailSoapFaultDefinitionExceptionResolver exceptionResolver = new DetailSoapFaultDefinitionExceptionResolver();
    
            SoapFaultDefinition soapFaultDefinition = new SoapFaultDefinition();
            soapFaultDefinition.setFaultCode( SoapFaultDefinition.SERVER );
            exceptionResolver.setDefaultFault( soapFaultDefinition );
    
            return exceptionResolver;
        }
    
    }
    

提交回复
热议问题