@ExceptionHandler没有在异常上被调用

时间:2018-06-28 13:56:24

标签: java spring rest spring-mvc soap

我正在将SOAP服务迁移到REST。我要做的是有一个wsdl定义,并使用它来自动使用JAXB生成请求和响应类。

这是我的终点

@Endpoint
public class RefundServiceEndpoint {

    @Autowired
    private RefundService refundService;

    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
    @ExceptionHandler(value = RefundException.class)
    public void handleException(RefundException exception) {
        // This should be called
    }

    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
    @ExceptionHandler(value = UnableToMapException.class)
    public void handleException(UnableToMapException exception) {
    // This should be called

    }

    @Autowired
    HttpServletRequest serverRequest;

    @PayloadRoot(namespace = NAMESPACE_URI, localPart = "ReturnRequest")
    @ResponsePayload
    public ReturnResponse returnRequest(@RequestPayload ReturnRequest request) {
        return this.refundService.partialRefund(request, serverRequest).getBody();
    }
}

我抛出了这两个异常,但是未调用处理程序。 我设法获得它们的唯一方法是尝试/捕获,但我试图避免这种情况。

谢谢

0 个答案:

没有答案