【发布时间】:2020-04-27 09:34:55
【问题描述】:
我正在将运行 java 1.7 和 jboss-eap-6.1 的应用程序迁移到 java 1.8 和 wildfly-18.0.0.Final。
一切运行良好,但我在使用 SOAP 调用特定的外部 Web 服务时遇到了问题。
调用服务时出现此错误:
Caused by: org.w3c.dom.DOMException: WRONG_DOCUMENT_ERR: A node is used in a different document than
the one that created it.
at com.sun.org.apache.xerces.internal.dom.ParentNode.internalInsertBefore(ParentNode.java:357)
at com.sun.org.apache.xerces.internal.dom.ParentNode.insertBefore(ParentNode.java:288)
at com.sun.org.apache.xerces.internal.dom.NodeImpl.appendChild(NodeImpl.java:237)
at org.apache.wss4j.dom.util.WSSecurityUtil.prependChildElement(WSSecurityUtil.java:375)
at org.apache.wss4j.dom.util.WSSecurityUtil.findWsseSecurityHeaderBlock(WSSecurityUtil.java:497)
at org.apache.wss4j.dom.message.WSSecHeader.insertSecurityHeader(WSSecHeader.java:167)
at org.apache.wss4j.dom.handler.WSHandler.doSenderAction(WSHandler.java:117)
at org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor.access$100(WSS4JOutInterceptor.java:57)
at org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor$WSS4JOutInterceptorInternal.handleMessageInternal(WSS4JOutInterceptor.java:275)
at org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor$WSS4JOutInterceptorInternal.handleMessage(WSS4JOutInterceptor.java:147)
at org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor$WSS4JOutInterceptorInternal.handleMessage(WSS4JOutInterceptor.java:132)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:530)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:441)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:356)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:314)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:140)
... 112 more
所有其他服务都在工作,除了这个。 当我查看 spring 上下文 xml 文件时,我看到这个服务有一个额外的配置,它是一个 WSS4JOutInterceptor bean。
<bean id="outInterceptorWSS" class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor">
<property name="properties">
<map>
<entry key="action" value="UsernameToken"/>
<entry key="mustUnderstand" value="false"/>
<entry key="user" value="username here"/>
<entry key="passwordType" value="PasswordNone"/>
<entry key="passwordCallbackClass"
value="PasswordHandler package here"/>
</map>
</property>
</bean>
<bean id="myServiceFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
<property name="serviceClass"
value="service package here"/>
<property name="address"
value="endpointUrl here"/>
<property name="username"
value="username here"/>
<property name="password"
value="password here"/>
<property name="outInterceptors" ref="outInterceptorWSS"/>
<property name="bus" ref="cxf"/>
</bean>
outInterceptorWSS bean 用于在调用外部Web 服务之前在soap 消息中添加安全标头。 该服务在迁移前运行良好(java 1.7 和 jboss-eap-6-1),但在迁移后无法运行(java 1.8 和 wildfly-18.0.0.Final)。
我不是 100% 确定,但我对这个问题的理解是,wildfly 创建了soap 消息,而spring 上下文xml 文件中定义的outInterceptorWS bean 试图修改它,因此消息: 一个节点在与创建它的文档不同的文档中使用
感谢任何帮助。 谢谢。
【问题讨论】:
-
你解决过这个问题吗?我现在面临同样的问题,运气不好。
-
嗨@dracuella 这是我们wildfly中库版本的问题。我们必须在 Wildfly 模块文件夹中手动添加良好版本的 jar。今天是星期六,我无法在家中访问我们的代码。星期一我会检查我们的代码,如果有的话,会给你更多的细节。
-
您是否找到有关您必须添加哪些罐子的任何详细信息?如果您升级或降级?
-
你好@dracuella。很抱歉,我答复晚了。您可以在下面查看我的答案以获取详细信息。希望能帮助到你。告诉我。