I have a J2EE app that (for legacy reasons) has both the Axis2 and CXF libraries used for different provider end-points both used by the application.
I have implemented a new client end-point that connects to a third party provider via CXF. The end points requires that authentication details are to to be placed into the SoapHeaders (and not HTTP headers).
The spring config is as below:
<jaxws:client id="fareSearchServicePort" serviceClass="org.openaxisgroup.axisschemadocs.v1r1_va.AxisPort"
address="${endpoint}faresearch">
<jaxws:features>
<ref bean="gzipFeature"/>
<ref bean="fastInfosetFeature"/>
<!--<ref bean="loggingFeature"/>-->
</jaxws:features>
<jaxws:properties>
<entry key="org.apache.cxf.binding.soap.messageFactoryClassName" value="com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl" />
</jaxws:properties>
<jaxws:outInterceptors>
<ref bean="outPasswordInterceptor" />
</jaxws:outInterceptors>
</jaxws:client>
<bean id="outPasswordInterceptor" class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor">
<constructor-arg>
<map>
<entry key="action" value="UsernameToken" />
<entry key="passwordType" value="PasswordText" />
<entry key="signaturePropFile" value="..."/>
<entry key="passwordCallbackRef" value-ref="myPasswordCallback"/>
</map>
</constructor-arg>
</bean>
Without the outInterceptors, the connection work's fine and simply fails to authenticate.
With the inclusion of the interceptor, somewhere along the line, the code is delegated to the Axis2 libraries resulting in "org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR". The is even before the password callback method is touched. The stacktrace:
org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted.
at org.apache.axiom.om.impl.dom.ParentNode.insertBefore(ParentNode.java:224)
at org.apache.axiom.om.impl.dom.NodeImpl.appendChild(NodeImpl.java:240)
at org.apache.axis2.saaj.SOAPPartImpl.appendChild(SOAPPartImpl.java:979)
at org.apache.cxf.staxutils.W3CDOMStreamWriter.setChild(W3CDOMStreamWriter.java:114)
at org.apache.cxf.staxutils.W3CDOMStreamWriter.newChild(W3CDOMStreamWriter.java:104)
at org.apache.cxf.staxutils.W3CDOMStreamWriter.writeStartElement(W3CDOMStreamWriter.java:132)
at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.writeSoapEnvelopeStart(SoapOutInterceptor.java:122)
at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.handleMessage(SoapOutInterceptor.java:81)
at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.handleMessage(SoapOutInterceptor.java:61)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:244)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:516)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:313)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:265)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:124)
at $Proxy144.axisTransaction(Unknown Source)
How do I specify the SOAPPartImpl to use? (ie. com.sun.xml.internal.messaging.saaj.soap.SOAPPartImpl)