如何在 JiBX 中禁用名称空间验证?

发布于 2024-12-08 17:52:31 字数 1203 浏览 2 评论 0原文

我有一个指定命名空间的 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 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文