如何在 JiBX 中禁用名称空间验证?
我有一个指定命名空间的 JiBX 绑定文件。但是,我想关闭命名空间验证,以便即使具有无效命名空间的 XML 消息也可以被解组。
我有一个如下所示的绑定文件:
<binding name="test_binding">
<namespace prefix="soapenv" uri="http://www.w3.org/2003/05/soap-envelope" />
<!-- Envelope -->
<mapping name="Envelope" ns="http://www.w3.org/2003/05/soap-envelope"
class="com.test.data.Envelope">
<structure get-method="getHeader" set-method="setHeader"
ns="http://www.w3.org/2003/05/soap-envelope" usage="optional" />
<structure get-method="getBody" set-method="setBody"
ns="http://www.w3.org/2003/05/soap-envelope" usage="optional" />
</mapping>
...
我将以下消息传递给 JiBX 解组器(信封元素具有不同的命名空间):
<?xml version="1.0" encoding="UTF-8" ?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope">
<soapenv:Header>
<MyElement>
....
下面显示了 JiBX 解组消息时的错误消息:
[Time:2011-10-04 17:39:29,802][Level:FATAL]org.jibx.runtime.JiBXException: No unmarshaller for element "{http://schemas.xmlsoap.org/soap/envelope}Envelope" (line 2, col 76)
...
有没有办法在 JiBX 中禁用命名空间验证?谢谢。
I have a JiBX binding file that specifies namespaces. However, I want to turn off namespace validation so that even an XML message with invalid namespace could be unmarshalled.
I have a binding file like the following:
<binding name="test_binding">
<namespace prefix="soapenv" uri="http://www.w3.org/2003/05/soap-envelope" />
<!-- Envelope -->
<mapping name="Envelope" ns="http://www.w3.org/2003/05/soap-envelope"
class="com.test.data.Envelope">
<structure get-method="getHeader" set-method="setHeader"
ns="http://www.w3.org/2003/05/soap-envelope" usage="optional" />
<structure get-method="getBody" set-method="setBody"
ns="http://www.w3.org/2003/05/soap-envelope" usage="optional" />
</mapping>
...
I pass the following message to JiBX unmarshaller (with different namespace for Envelope element):
<?xml version="1.0" encoding="UTF-8" ?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope">
<soapenv:Header>
<MyElement>
....
The following shows the error message when JiBX unmarshalls the message:
[Time:2011-10-04 17:39:29,802][Level:FATAL]org.jibx.runtime.JiBXException: No unmarshaller for element "{http://schemas.xmlsoap.org/soap/envelope}Envelope" (line 2, col 76)
...
Is there a way to disable namespace validation in JiBX? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论