类型为ElementNSImpl的对象以com.sun.org.apache.xerces.internal.dom.ElementNSImpl

时间:2018-10-25 19:33:36

标签: java xml soap ws-trust

因此,我在JDK1.8.0_161环境中部署的WS-Trust服务器期望的请求将包含类型为org.apache.xerces.dom.ElementNSImpl的xml节点,但是当请求到达时,这些节点的类型为com.sun.org.apache.xerces.internal.dom.ElementNSImpl,这并不会让我无法从请求中读取数据。我正在使用xerces:xercesImpl:2.11.0库,但想知道JDK是否搞乱了服务器端的请求解析。目前,我只看到包含rt.jar的{​​{1}}。我想念什么?有没有人看到这个错误?

1 个答案:

答案 0 :(得分:0)

我通过使用Element作为接口而不是使用实现ElementNSImpl解决了这个问题。这将使实现环境独立。

所以代码看起来像这样

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

代替

if(object instanceof ElementNSImpl)