Announcement Announcement Module
Collapse
No announcement yet.
PayloadValidatingInterceptor doesn't validate response Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • PayloadValidatingInterceptor doesn't validate response

    PayloadValidatingInterceptor seems to allow just about anything. I can define an element as "xs:integer", yet still set it to a non-integer value in my xml message. The only thing it seems to do is validate the schema when the applicationContext is loaded.

    From the spring-ws-servlet.xml:
    Code:
    <bean id="validatingInterceptor"
            class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
    	<property name="schemas">
    		<list>
    			<value>/WEB-INF/wsdl/general.xsd</value>
    		</list>
    	</property>
    	<property name="validateRequest" value="false"/>
    	<property name="validateResponse" value="true"/>
    </bean>
    
    <bean id="endpointMapping" class="org.springframework.ws.soap.server.endpoint.mapping.SoapActionEndpointMapping">
    	<property name="mappings">
    		<props>
    			<prop key="urn:getServerVersion">getServerVersionEndpoint</prop>
    		</props>
    	</property>
    	<property name="interceptors">
    		<list>
    			<ref local="loggingInterceptor"/>
    			<ref local="validatingInterceptor"/>
    		</list>
    	</property>
    </bean>
    The contents of general.xsd:
    Code:
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:ns="http://general/xsd/"
            elementFormDefault="qualified"
            attributeFormDefault="qualified"
            targetNamespace="http://general/xsd/">
    
    	<xs:element name="getServerVersionResponse">
    		<xs:complexType>
    			<xs:sequence>
    				<xs:element minOccurs="0" name="return" nillable="false" type="xs:integer"/>
    			</xs:sequence>
    		</xs:complexType>
    	</xs:element>
    </xs:schema>

    And now, the xml message that SHOULD cause a validation exception, because the value of "return" is not an integer:
    Code:
    <ns:getServerVersionResponse xmlns:ns="http://general/xsd/">
            <ns:return>4.9.0</ns:return>
    </ns:getServerVersionResponse>
    Have I just completely missed something here?

  • #2
    It looks like you have turned off validation on the request:

    <bean id="validatingInterceptor"
    class="org.springframework.ws.soap.server.endpoint .interceptor.PayloadValidatingInterceptor">
    <property name="schemas">
    <list>
    <value>/WEB-INF/wsdl/general.xsd</value>
    </list>
    </property>
    <property name="validateRequest" value="false"/>
    <property name="validateResponse" value="true"/>
    </bean>

    Comment


    • #3
      Originally posted by boz0413 View Post
      It looks like you have turned off validation on the request:

      Yes, that is my intent. I only want to validate the response that I send back to the client, but the PayloadValidatingInterceptor does not honor my xs:integer definition in the schema.

      Comment


      • #4
        Hi,
        Were you able to solve this issue? I'm getting the same error. Pls let me know if you have solution.

        Comment


        • #5
          No, I never got it to work.

          I have moved on to a new project since then.

          Comment


          • #6
            PayloadValidatingInterceptor does not throw an exception or return fault if the response is not valid. It only logs WARNing. It actually makes sense, you usually do not want to return fault in such case.

            Comment

            Working...
            X