使用CXF 2.3.1在出站消息中不会发生JAXB模式验证 [英] JAXB schema validation not occurring in outbound message with CXF 2.3.1

查看:80
本文介绍了使用CXF 2.3.1在出站消息中不会发生JAXB模式验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用CXF 2.3.1。

Using CXF 2.3.1.

使用JAXB从WSDL生成Java。

Generated Java from WSDLs using JAXB.

使用

<jaxws:properties>
    <entry key="schema-validation-enabled" value="true" />
</jaxws:properties>

我的test创建一个不符合WSDL特定要求的对象:

My test creates an object that fails this particular requirement of the 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>

然而,消息被编组并一直通过传出的拦截器链。

However, the message is marshalled and makes it all the way through the outgoing interceptor chain.

WSDL是单向的:仅输入。

The WSDL is one-way: input-only.

wsdlLocation在Impls的注释中指定。

wsdlLocation is specified in an annotation in the Impls.

有趣的是,在解组时,拦截链会阻止验证此相同约束的传入消息。

Interestingly, incoming messages that fail validation of this same constraint are blocked by the interceptor chain during unmarshalling.

我'在WebLogic上进行测试。我也可以在WebSphere上进行测试。

I'm testing on WebLogic. I could also test on WebSphere is needed.

其他XSD验证失败(例如缺少必需的元素)正被传出的编组捕获。

Other XSD validation failures (such as a missing required element) are being caught by the outgoing marshaller.

我们从2.2.6升级到CXF 2.3.1的原因是我们在入站消息中看到了类似的问题。在2.3.1中,对入站邮件进行完整的XSD验证,但对出站邮件不进行验证。

The reason that we upgraded to CXF 2.3.1 from 2.2.6 was that we were seeing similar issues on the inbound messages. In 2.3.1, complete XSD validation occurs for inbound messages but not for outbound ones.

以下是CXF中的错误:

Here is the bug in CXF:

https://issues.apache.org/jira/browse/CXF- 3233

我们在将消息发送到CXF拦截器链之前使用org.springframework.xml.validation.XmlValidator进行验证。我希望修复使用CXF拦截器链。但是,我怀疑这是CXF中的一个错误。

We worked around this by using org.springframework.xml.validation.XmlValidator to validate before sending the message to the CXF interceptor chain. I'm hoping for fixes that use the CXF interceptor chain. However, I suspect that this is a bug in CXF.

推荐答案

我遇到过类似的问题(CXF 2.2.7)和能够通过将 serviceName endpointName 属性添加到我的< jaxws来解决它:客户端> bean定义。请在此处查看配置Spring客户端(选项1)部分: https:/ /cwiki.apache.org/CXF20DOC/jax-ws-configuration.html 了解有关属性的更多信息。

I've had similar problems (CXF 2.2.7) and was able to solve it by adding the serviceName and endpointName attributes to my <jaxws:client> bean definition. check out the section "Configuring a Spring Client (Option 1)" here: https://cwiki.apache.org/CXF20DOC/jax-ws-configuration.html for more information on the attributes.

注意:我也有 wsdlLocation 也定义了属性。这可能是CXF找到服务使用的XSD所必需的。

Note: I also have the wsdlLocation attribute defined as well. This is likely necessary for CXF to find the XSDs used by the service.

这是我的一个例子:

<jaxws:client id="client"
              serviceClass="com.example.ServiceInterface"
              address="http://example.com/endpoint"
              wsdlLocation="WEB-INF/wsdl/SampleWSDLFile.wsdl"
              serviceName="s:SampleService"
              endpointName="s:SampleServicePort"
              xmlns:s="http://www.example.com/some/namesapce">
...
</jaxws:client>

我也注意到当我遇到这个问题时,整个架构被<$打印到我的日志文件中每次调用客户端时,c $ c> org.apache.cxf.wsdl.EndpointReferenceUtils 类。当我像上面那样设置我的客户端bean时,这种行为就消失了。我想知道你是否也会看到类似的东西...

I also noticed when I had this problem the whole schema was printed to my log file by the org.apache.cxf.wsdl.EndpointReferenceUtils class every time the client was invoked. This behavior went away when I setup my client bean like the one above. I wonder if you're seeing something like that too...

我应该提到的另一个细节是,当我没有时,我有很多来自CXF的意外行为使用 WHICH_JARS 文件中列出的所有CXF提供的库。我也会尝试将它们添加到构建中,以便它们覆盖任何服务器或Java提供的库。如果没有必要,您可以随后将其删除。

Another detail I should mention is that I had a lot of unexpected behavior from CXF when I didn't use all the CXF-provided libraries outlined in the WHICH_JARS file. I would also try adding them to the build so they override any server or Java provided libraries. You can always remove them later if they aren't necessary.

这篇关于使用CXF 2.3.1在出站消息中不会发生JAXB模式验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆