简体   繁体   English

根据 WSDL 验证 SOAP 消息

[英]Validate SOAP message against WSDL

Just like validating an XML file against an XML Schema Definition in Java is there a way to validate an XML file that contains a SOAP Envelope against a WSDL file? Just like validating an XML file against an XML Schema Definition in Java is there a way to validate an XML file that contains a SOAP Envelope against a WSDL file?

Some web service containers provide this functionality.一些 web 服务容器提供此功能。 JBoss 3.0.1+ does this with the @SchemaValidation annotation: JBoss 3.0.1+ 使用 @SchemaValidation 注释执行此操作:

http://community.jboss.org/wiki/JBossWS-NativeUserGuide#SchemaValidation http://community.jboss.org/wiki/JBossWS-NativeUserGuide#SchemaValidation

If you are using Spring-WS, this can be done by using an interceptor along these lines:如果您使用的是 Spring-WS,这可以通过使用拦截器来完成:

<sws:interceptors>
    <sws:payloadRoot namespaceUri="...">
        <bean id="validatingInterceptor"
            class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
            <property name="schema" value="classpath:/wsdl/schema.xsd" />
            <property name="validateRequest" value="true" />
            <property name="validateResponse" value="true" />
        </bean>
    </sws:payloadRoot>
</sws:interceptors>

With CXF, here is an approach:使用 CXF,这是一种方法:

http://cxf.apache.org/faq.html#FAQ-HowcanIturnonschemavalidationforjaxwsendpoint%3F http://cxf.apache.org/faq.html#FAQ-HowcanIturnonschemavalidationforjaxwsendpoint%3F

There is a tool developed by Ivan Krivyakov which validates the req or resp XMLs based on the WSDL and / or XSD provided. Ivan Krivyakov 开发了一个工具,它基于提供的 WSDL 和/或 XSD 验证 req 或 resp XML。 The tool is available at http://www.codeproject.com/Articles/182406/Validating-SOAP-Message-against-WSDL (requires you to create a login though.)该工具可在http://www.codeproject.com/Articles/182406/Validating-SOAP-Message-against-WSDL获得(尽管需要您创建一个登录名。)

I don't know simple way.我不知道简单的方法。 In our project we just copy and paste element from WSDL to XSD file.在我们的项目中,我们只是将元素从 WSDL 复制并粘贴到 XSD 文件中。 You can write an util class which will make this work instead of you.您可以编写一个实用程序 class 来代替您完成这项工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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