使用 CXF 2.3.1。
使用 JAXB 从 WSDL 生成 Java。
使用
<jaxws:properties>
<entry key="schema-validation-enabled" value="true" />
</jaxws:properties>
在客户端配置中。
我的测试创建了一个不符合 WSDL 特定要求的对象:
<xsd:simpleType name="UUID.Content">
<xsd:annotation>
<xsd:documentation xml:lang="EN">
Universally Unique Identifier
</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:token">
<xsd:length value="36" />
<xsd:pattern
value="[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}" />
</xsd:restriction>
</xsd:simpleType>
但是,消息被编组并通过传出拦截器链一直传递。
WSDL 是单向的:仅输入。
wsdlLocation 在 Impls 的注释中指定。
有趣的是,未通过相同约束验证的传入消息在解组期间被拦截器链阻止。
我正在测试 WebLogic。我还可以在需要 WebSphere 上进行测试。
传出编组器正在捕获其他 XSD 验证失败(例如缺少必需元素)。
我们从 2.2.6 升级到 CXF 2.3.1 的原因是我们在入站消息中看到了类似的问题。在 2.3.1 中,对入站消息进行完整的 XSD 验证,但对出站消息不进行。
这是CXF中的错误:
https://issues.apache.org/jira/browse/CXF-3233
我们通过使用 org.springframework.xml.validation.XmlValidator 在将消息发送到 CXF 拦截器链之前进行验证来解决这个问题。我希望修复使用 CXF 拦截器链。但是,我怀疑这是 CXF 中的错误。