首页 > 解决方案 > ElementNSImpl 类型的对象以 com.sun.org.apache.xerces.internal.dom.ElementNSImpl 的形式出现

问题描述

所以我部署在 JDK1.8.0_161 环境中的 WS-Trust 服务器期待一个包含 xml 类型节点的org.apache.xerces.dom.ElementNSImpl请求,但是当请求到来时,节点是 type com.sun.org.apache.xerces.internal.dom.ElementNSImpl,这不会让我不从请求中读取数据。我正在使用xerces:xercesImpl:2.11.0库,但想知道 JDK 是否弄乱了服务器端的请求解析。目前我只看到rt.jar包含com.sun.org.apache.xerces.internal.dom.ElementNSImpl. 我错过了什么?有没有人看到这个错误?

标签: javaxmlsoapws-trust

解决方案


我通过使用Elementas interface 而不是使用 implementation解决了这个问题ElementNSImpl。这将使实现环境独立。

所以代码看起来像这样

if(object instanceof org.w3c.dom.Element)

代替

if(object instanceof ElementNSImpl)

推荐阅读