我一直在努力使用 PayloadValidatingInterceptor,我使用的是 spring 3.2,并且在我的 web 服务中我只有 Request,因为我的服务很容易忘记。
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:sws="http://www.springframework.org/schema/web-services"
xmlns:oxm="http://www.springframework.org/schema/oxm"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/web-services
http://www.springframework.org/schema/web-services/web-services.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/oxm
http://www.springframework.org/schema/oxm/spring-oxm.xsd">
PayloadValidatingInterceptor is not firing at all: here is the configuration:
<sws:interceptors>
<bean id="validatingInterceptor"
class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
<property name="schema" value="/WEB-INF/erass-ingest.xsd"/>
<property name="validateRequest" value="true"/>
<property name="validateResponse" value="false"/> </bean>
</sws:interceptors>
这是我的 XSD 的标题:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.cbsa-asfc.gc.ca/erass/schema/ingest" xmlns:common="http://www.cbsa-asfc.gc.ca/erass/schema/common" targetNamespace="http://www.cbsa-asfc.gc.ca/erass/schema/ingest" elementFormDefault="qualified" attributeFormDefault="unqualified" version="0.4">
<xs:import namespace="http://www.cbsa-asfc.gc.ca/erass/schema/common" schemaLocation="erass-common-types.xsd"/>
<xs:import namespace="http://www.cbsa-asfc.gc.ca/erass/schema/common" schemaLocation="erass-simple-types.xsd"/>
<xs:element name="IngestionData">
这是我的端点:
@Endpoint
public class IngestionEndpoint {
private static final Logger logger = LoggerFactory.getLogger(IngestionEndpoint.class);
private static final String INGESTION_REQUEST = "IngestionData";
private static final String NAMESPACE_URI = "http://www.cbsa-asfc.gc.ca/erass/schema/ingest";
@Autowired
private IngestionService service;
public IngestionEndpoint() {
super();
}
public IngestionEndpoint(IngestionService service) {
this.service = service;
}
@PayloadRoot(localPart = INGESTION_REQUEST, namespace=NAMESPACE_URI)
public void handleIngestRequest(@RequestPayload IngestionData data) {
try {
service.ingest(data);
} catch (Throwable t) {
logger.error("An error occurred ingesting data XXX", t);
}
}