0

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)

1 Answers1

0

You don't mention the version of CXF used. Definitely try using the latest version (2.6.2 right now, although 2.6.3 is being voted on now). There has been some work recently on getting the various older SAAJ implementations usable. Just updating to the latest CXF might fix it.

If that doesn't help, you can set a system property of "org.apache.cxf.binding.soap.messageFactoryClassName" and/or "org.apache.cxf.binding.soap.soapFactoryClassName" to the appropriate Sun class name and the should work.

Daniel Kulp
  • 14,447
  • 4
  • 45
  • 37
  • The CXF version I am using is 2.2.10 and the version of Axis is AXIS2 1.4.1 . Looks like org.apache.cxf.binding.soap.messageFactoryClassName isn't available as a system property with that version of CXF. Have also tried bumping the AXIS2 version (to the latest and greatest) but that doesn't appear to fix things either. Was holding off doing the CXF upgrade due to the fact it needs all it's dependencies upgraded as well (WSS4J) that this is a legacy app is tied to.. – paddy mcpaddison Oct 09 '12 at 11:29
  • Just to bring some closure to this issue (and help others who have the same problem), it look's like it's not possible to upgrade CXF with the version of AXIS2 mentioned. This is because they both have dependancies on the XmlSchema lib, but they both need different versions.. So I ended up using AXIS2 and JAxB for databindings.. – paddy mcpaddison Oct 12 '12 at 05:36