2
我有一個應用程序,我想自動驗證收到和發送的郵件。我已經把它貼在PayloadValidatingInterceptor
並設置我想它要使用的模式:PayloadValidatingInterceptor不會觸發@Endpoint?
@EnableWs
@Configuration
public class WebServiceConfig extends WsConfigurerAdapter {
@Autowired
private ApplicationContext ctx;
@Bean
public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setApplicationContext(applicationContext);
// modifies the wsdl to serve the correct locations
servlet.setTransformWsdlLocations(true);
return new ServletRegistrationBean(servlet, "/*");
}
@Bean
protected PayloadValidatingInterceptor getValidatingInterceptor() {
PayloadValidatingInterceptor validatingInterceptor = new PayloadValidatingInterceptor();
validatingInterceptor.setSchema(getResource("classpath:CARetriever.xsd"));
validatingInterceptor.setValidateRequest(true);
validatingInterceptor.setValidateResponse(true);
return validatingInterceptor;
}
private Resource getResource(String resource) {
return ctx.getResource(resource);
}
}
我可以看到攔截器是越來越加載
2016-01-21 14:22:08 INFO org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor,164 - Validating using class path resource [CARetriever.xsd]
然而,當我把反對無效的SOAP消息它,我得到一個NullPointerException
而不是驗證消息。所以,無論是我的配置還是期望都是錯誤的。有人可以指向哪個?
請分享該'NPE'的StackTrace。從另一方面,我沒有看到'addInterceptors(List攔截器)'實現用於將'PayloadValidatingInterceptor'添加到端點映射... –
我沒有收到堆棧跟蹤 - 錯誤是在soap故障響應中返回的。至於'addInterceptors' - 當我嘗試用該方法添加它時,它不再出現在日誌中。 –
這很糟糕。任何故障都是服務器上的問題。你應該調試你的服務來找出那個NPE中有罪的人。回覆。 'addInterceptors()' - 我不知道它應該如何工作......這是你的應用程序,我們只能推薦和修復一些明顯的問題。所有其他你的願望取決於你。 –