Spring Web Services - Exception Skipping ExceptionResolver

前端 未结 8 953
别那么骄傲
别那么骄傲 2020-12-19 04:33

I have a SOAP service, the request and responses work as expected with good input, if I specify bad input for an XML element

in request body:

...
<         


        
相关标签:
8条回答
  • 2020-12-19 05:28

    You have to "wire" (or "inject") the exception handler in your spring beans. I'm not sure which of your Spring bean actually needs the exception handler.

    Personally, I use default-autowire="byName", which cause my exceptionHandler to be wired in my Controller class automatically. Your approach actually use manual wiring. So you need to find out which bean should actually use the exception handler. Have you tried (just on top of my head):

    <bean class="org.springframework.ws.server.endpoint.adapter.MarshallingMethodEndpointAdapter">
        <constructor-arg ref="marshaller"/>
        <property name="exceptionHandler" ref="exceptionHandler" />
    </bean>
    

    Or you could just add the autowired mechanism of Spring and let it wire the beans automatically. :)

    0 讨论(0)
  • 2020-12-19 05:31

    The MessageDispatcherServlet creates its own two instances of EnpointExceptionResolver by default, namely SoapFaultAnnotationExceptionResolver@1 and SimpleSoapExceptionResolver@2

    And when it resolves an exception the SimpleSoapExceptionResolver@2 will stop any other registered EnpointExceptionResolver to handle an exception.

    It took me embarrassingly long to figure out, but the answer is quite simple, in your servlet context you have to do this:

    <bean id="exceptionResolver" class="com.wdp.smm.ws.MyExceptionResolver">
        <property name="order" value="1"/>
    </bean>
    
    0 讨论(0)
提交回复
热议问题