如果他们的XSD具有唯一粒子属性错误,我如何验证Spring Web Services中的SPML SOAP请求?

时间:2013-01-08 13:05:25

标签: spring xsd spring-ws xsd-validation spml

我想知道是否有人能指出我在这方面正确的方向。

我正在开发一个项目,需要创建Web服务功能以遵守SPML v2规范(https://www.oasis-open.org/committees/tc_home.php?wg_abbrev=provision)。它是用于配置服务的基于XML的规范。

我已经创建了映射到SOAP请求的名称空间和localpart的端点。我的问题在于尝试使用规范本身提供的XSD来验证spring Web服务中的有效负载请求。根据我的研究,它是一个“开放内容模型”,任何验证或尝试编译XSD都会导致唯一粒子归因错误。

这是因为CORE XSD具有“ExtensibleType”complexType,当其他complexTypes从中扩展时会导致错误。根据我的研究,我可以看到错误发生的原因,但我不想修改规范本身提供的xsds。

示例:

<complexType name="ExtensibleType">
    <sequence>
        <any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
    </sequence>
    <anyAttribute namespace="##other" processContents="lax"/>
</complexType>



<complexType name="SearchQueryType">
    <complexContent>
        <extension base="spml:ExtensibleType">  
            <sequence>
                <annotation>
                    <documentation>Open content is one or more instances of QueryClauseType (including SelectionType) or LogicalOperator.</documentation>
                </annotation>

                <element name="basePsoID" type="spml:PSOIdentifierType"  minOccurs="0" />
            </sequence>
            <attribute name="targetID" type="string" use="optional"/>
            <attribute name="scope" type="spmlsearch:ScopeType" use="optional"/>
        </extension>
    </complexContent>               
</complexType>

尝试验证xsds时会出现以下错误:

cos-nonambig:WC [## other:“urn:oasis:names:tc:SPML:2:0”]和“urn:oasis:names:tc:SPML:  2:0:搜索“:basePsoID(或来自其替换组的元素)违反”唯一粒子  归因“。在针对此模式进行验证期间,将为这两个模式创建歧义  颗粒

由于XSD本身无效,我有一段时间无法确定如何根据规范本身提供的XSDS实际验证有效负载请求。

在spring上下文文件中添加PayloadValidatingInterceptor会在服务器尝试启动时导致相同的错误:

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

感谢提前任何人的意见,不确定是否有人遇到过此类问题。

达米安

1 个答案:

答案 0 :(得分:0)

您需要做的是禁用Unique Particle Attribution检查。一般来说,这适用于Java(请参阅此SO post),您只需要找到一种方法来配置它...最糟糕的情况可能是基于上面的链接构建自己的验证器 - 它应该工作自Spring的XSD架构正在使用Apache的实现。