xs:restriction 在 Spring WS 中不起作用

发布于 2024-11-27 14:46:54 字数 525 浏览 5 评论 0原文

我这样定义了我的 xsd(部分):

            <xs:element name="entityNo" minOccurs="1" maxOccurs="1">
                <xs:simpleType>
                    <xs:restriction base="xs:string">
                        <xs:minLength value="1"/>
                        <xs:maxLength value="20"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:element>

但是当我使用 SoapUI 发送长度超过 20 的字符串时,我的端点仍然会收到它,就好像它是有效输入一样。 我该如何解决这个问题?

I defined my xsd this way (partial):

            <xs:element name="entityNo" minOccurs="1" maxOccurs="1">
                <xs:simpleType>
                    <xs:restriction base="xs:string">
                        <xs:minLength value="1"/>
                        <xs:maxLength value="20"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:element>

but when i send with SoapUI a string longer than 20 my Endpoint still receives it as if it was a valid input.
How can i fix this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

比忠 2024-12-04 14:46:54

好的,限制有效,我只需在 spring-ws 配置文件中添加 PayloadValidatingInterceptor 拦截器:

<sws:interceptors>
<bean class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
    <property name="schemas">
        <list>
            <value>/WEB-INF/schemasDef/first.xsd</value>
            <value>/WEB-INF/schemasDef/second.xsd</value>
        </list>
    </property>
    <property name="validateRequest" value="true"/>
    <property name="validateResponse" value="true"/>
</bean>
</sws:interceptors>

OK, restriction works, i just had to add the PayloadValidatingInterceptor interceptor in spring-ws config file:

<sws:interceptors>
<bean class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
    <property name="schemas">
        <list>
            <value>/WEB-INF/schemasDef/first.xsd</value>
            <value>/WEB-INF/schemasDef/second.xsd</value>
        </list>
    </property>
    <property name="validateRequest" value="true"/>
    <property name="validateResponse" value="true"/>
</bean>
</sws:interceptors>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文