简体   繁体   中英

Spring web services validation

I've two kinds of webservices:

  1. webservices that need the request to be validated
  2. others that must not be validated by Spring.

Is this possible in Spring?

I know about ValidatingInterceptor , but can we have two of these?

The reason for not validating one type of web service is that the request is not defined: what's sent in the request, depends on many things.

I am using Spring 3.0, with schema XSD's for my webservices.

Any suggestions? Adi

You can use two payloadroot within a interceptor for that purpose.

All you need to do is to set validateRequest / validateResponse as true or false as required.

Here is a sample:

<sws:interceptors>
    <sws:payloadRoot namespaceUri="uri1">
        <bean id="validator1forUri1"
            class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor"
            p:schema="classpath:/WEB-INF/xsds/tovalidate.xsd" p:validateRequest="true"
            p:validateResponse="true" />
    </sws:payloadRoot>

    <sws:payloadRoot namespaceUri="uri2">
        <bean id="validator2forUri2"
            class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor"
            p:schema="classpath:/WEB-INF/xsds/nottovalidate.xsd"
            p:validateRequest="false" p:validateResponse="false" />
    </sws:payloadRoot>
</sws:interceptors>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM