ws 消息验证器中的多个 xsd 模式 - 为什么在 schemaCollection 中找不到资源但在 xsdSchema 中找到资源?

Multiple xsd schemas in ws message validator - why is the resource not found in schemaCollection but found in xsdSchema?

我正在尝试找出使用 SimpleXsdSchema 设置 XSD 资源的原因

<bean id="xsdSchema" class="org.springframework.xml.xsd.SimpleXsdSchema">
    <property name="xsd" value="/WEB-INF/schema.xsd"/>
</bean>

而使用 CommonsXsdSchemaCollection 则不会。我打算用它来提供多个 xsd 的。我更喜欢这种方法来相互导入 xsd。

<bean id="schemaCollection"
      class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection">
    <!--<property name="resourceLoader" ref="resourceLoader"/>-->
    <property name="xsds">
        <list>
            <value>/WEB-INF/schema.xsd"</value>
        </list>
    </property>
    <property name="inline" value="true" />
</bean>

当按照下面的标记使用它时,错误是:ServletContext resource [/WEB-INF/schema.xsd"] does not exit

正是

 Error creating bean with name 'org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor#0' defined in ServletContext resource [/WEB-INF/security-context.xml]: 
 Cannot resolve reference to bean 'schemaCollection' while setting bean property 'schemaCollection'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating  bean with name 'schemaCollection' defined in ServletContext resource [/WEB-INF/security-context.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: ServletContext resource [/WEB-INF/schema.xsd"] does not exit

用法:

    <bean class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
        <property name="errorHandler" ref="customValidationErrorHandler"/>
        <!--<property name="xsdSchema" ref="xsdSchema"/>-->
        <property name="schemaCollection" ref="schemaCollection"/>
    </bean>

有人知道吗? 有没有我应该使用的资源加载器? (该应用程序在 war 中打包并部署到应用程序服务器,在那里它仍未展开)。

您的配置有错别字:

        <value>/WEB-INF/schema.xsd"</value>

这应该是:

        <value>/WEB-INF/schema.xsd</value>