Spring WS - 使用 PayloadValidatingInterceptor 验证单个 SOAP Web 服务
Spring WS - Use PayloadValidatingInterceptor to validate a single SOAP Web Service
我有一个公开多个 SOAP 端点的项目。我想使用 Spring WS 提供的 PayloadValiditatingInterceptor 来仅验证特定的端点。但是,我当前的实现是对每个 SOAP 端点应用验证。
源码如下:
@Bean(name = "requestMessage")
public SimpleXsdSchema requestMessage()
{
return new SimpleXsdSchema(new ClassPathResource("com/schemas/2_0/requestMessage.xsd"));
}
@Override
public void addInterceptors(List<EndpointInterceptor> interceptors)
{
PayloadValidatingInterceptor validatingInterceptor = new PayloadValidatingInterceptor();
validatingInterceptor.setValidateRequest(true);
validatingInterceptor.setXsdSchema(requestMessage());
interceptors.add(validatingInterceptor);
}
我能够通过删除 addInterceptors 方法并在配置 class 中添加以下行来实现这一点。
public class SoapConfig extends WsConfigurerAdapter
{
@Bean
PayloadValidatingInterceptor myEndpointValidatingInterceptor() {
PayloadValidatingInterceptor interceptor = new
PayloadValidatingInterceptor();
interceptor.setValidateRequest(true);
interceptor.setXsdSchema(requestMessage());
return interceptor;
}
@Bean
PayloadRootSmartSoapEndpointInterceptor myEndpointValidator() {
return new
PayloadRootSmartSoapEndpointInterceptor(myEndpointValidatingInterceptor(),
RequestEndPoint.NAMESPACE, RequestEndPoint.REQUEST_LOCAL_PART);
}
}
我有一个公开多个 SOAP 端点的项目。我想使用 Spring WS 提供的 PayloadValiditatingInterceptor 来仅验证特定的端点。但是,我当前的实现是对每个 SOAP 端点应用验证。
源码如下:
@Bean(name = "requestMessage")
public SimpleXsdSchema requestMessage()
{
return new SimpleXsdSchema(new ClassPathResource("com/schemas/2_0/requestMessage.xsd"));
}
@Override
public void addInterceptors(List<EndpointInterceptor> interceptors)
{
PayloadValidatingInterceptor validatingInterceptor = new PayloadValidatingInterceptor();
validatingInterceptor.setValidateRequest(true);
validatingInterceptor.setXsdSchema(requestMessage());
interceptors.add(validatingInterceptor);
}
我能够通过删除 addInterceptors 方法并在配置 class 中添加以下行来实现这一点。
public class SoapConfig extends WsConfigurerAdapter
{
@Bean
PayloadValidatingInterceptor myEndpointValidatingInterceptor() {
PayloadValidatingInterceptor interceptor = new
PayloadValidatingInterceptor();
interceptor.setValidateRequest(true);
interceptor.setXsdSchema(requestMessage());
return interceptor;
}
@Bean
PayloadRootSmartSoapEndpointInterceptor myEndpointValidator() {
return new
PayloadRootSmartSoapEndpointInterceptor(myEndpointValidatingInterceptor(),
RequestEndPoint.NAMESPACE, RequestEndPoint.REQUEST_LOCAL_PART);
}
}