At somepoint tomorrow, it would be great if someone would try with the 2.6.0-SNAPSHOT jars that should be built tonight. (or build cxf's trunk yourself)
I just committed a bunch of updates that may allow CXF to actually work with the ancient SAAJ implementation that Websphere includes. I was able to reproduce the HIERARCHY_REQUEST_ERR by modifying one of our system tests to force using a hacked saaj impl pulled from the Websphere jars (don't ask) and managed to work around most of the issues. For simple SAAJ usage, it might actually work. The areas I know will still be problematic are: 1) SOAP 1.2 support - the SAAJ 1.1 API's WebSphere uses doesn't really allow creating SOAP 1.2 based SAAJ messages. 2) Signing/encrypting - the new xmlsec libs that we need make use of DOM level 3 API's which are not on the Websphere SAAJ impl. Thus, that is likely to not work. HOWEVER, I did discover something else. If you can set a system property prior to calling the CXF stuff, you MAY be able to get around the automatic detection of the IBM implementation. CXF checks two system properties: org.apache.cxf.binding.soap.messageFactoryClassName org.apache.cxf.binding.soap.soapFactoryClassName which are the classnames for the SAAJ MessageFactory and SOAPFactory classes that you specifically want CXF to use. You might be able to set it to: com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl and com.sun.xml.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl to pickup the version in the saaj-impl jar. Not really sure though. Dan On Friday, March 09, 2012 12:37:39 PM yuplushu wrote: > Glen, > > Thanks for quick response. I tried a couple of ways to add > SOAPHeader, including SOAPHandler, all worked fine in stand alone. The > problem is once the jars in Wephere 6.1 are included, variety of errors > are thrown. I can't get rid of those jars. For using SOAPHandler, the > error is : > > Mar 9, 2012 2:25:59 PM org.apache.cxf.phase.PhaseInterceptorChain > doIntercept WARNING: Interceptor has thrown exception, unwinding now > org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to > insert a node where it is not permitted. at > org.apache.xerces.dom.CoreDocumentImpl.insertBefore(Unknown Source) at > org.apache.xerces.dom.NodeImpl.appendChild(Unknown Source) > at > com.ibm.ws.webservices.engine.xmlsoap.SOAPPart.appendChild(SOAPPart.java: > 282) at > org.apache.cxf.staxutils.W3CDOMStreamWriter.setChild(W3CDOMStreamWriter.j > ava:114) at > org.apache.cxf.staxutils.W3CDOMStreamWriter.newChild(W3CDOMStreamWriter.j > ava:104) at > org.apache.cxf.staxutils.W3CDOMStreamWriter.writeStartElement(W3CDOMStrea > mWriter.java:132) at > org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.writeSoapEnvel > opeStart(SoapOutInterceptor.java:121) at > org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.handleMessage( > SoapOutInterceptor.java:80) at > org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.handleMessage( > SoapOutInterceptor.java:61) at > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorCh > ain.java:236) at > org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:483) at > org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:309) at > org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:261) at > org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73) at > org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:124) > at $Proxy38.createProgram100(Unknown Source) > at client.glen.mazzas.WSClient.main(WSClient.java:83) > javax.xml.ws.soap.SOAPFaultException: HIERARCHY_REQUEST_ERR: An attempt > was made to insert a node where it is not permitted. at > org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:146) > at $Proxy38.createProgram100(Unknown Source) > at client.glen.mazzas.WSClient.main(WSClient.java:83) > > > > > --- On Fri, 3/9/12, Glen Mazza (Talend) [via CXF] > <[email protected]> wrote: > > > From: Glen Mazza (Talend) [via CXF] > <[email protected]> Subject: Re: cxf 2.2.5 ws > client in websphere v6.1, got ClassCastException error To: "yuplushu" > <[email protected]> > Date: Friday, March 9, 2012, 11:44 AM > > > Not to say that it doesn't exist, but I haven't seen that way of adding > SOAP Headers before (it almost looks like a way to add HTTP headers > instead). Links #43 and #44 here: > http://www.jroller.com/gmazza/entry/blog_article_index show alternative > ways of adding SOAP headers using interceptors or JAX-WS Handlers. If > no one else can fix your code below you may wish to look at those methods. > > Regards, > Glen > > On 03/09/2012 11:49 AM, yuplushu wrote: > > CXF 2.2.5 client call web service operation from ear that deployed to > > webphere application server v6.1. It works fine untill a SOAP header is > > added as: > > > > DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); > > DocumentBuilder db = dbf.newDocumentBuilder(); > > Document d = db.newDocument(); > > Element dummy = d.createElement("dummy"); > > dummy.setTextContent("Dummy Header"); > > Header dummyHeader = new Header(new QName("urn:dummySpace", > > "dummyHeader"), dummy); > > List<Header> headersList = new ArrayList<Header>(); > > headersList.add(dummyHeader); > > bindingProvider.getRequestContext().put(Header.HEADER_LIST, > > headersList); > > > > Then get error: > > > > PhaseIntercep W org.apache.cxf.phase.PhaseInterceptorChain doIntercept > > Interceptor has thrown exception, unwinding now > > java.lang.ClassCastException: > > org.apache.cxf.headers.Header incompatible with > > org.apache.cxf.headers.Header > > at > > org.apache.cxf.binding.soap.interceptor.SoapHeaderOutFilterInterceptor.h > > andleMessage(SoapHeaderOutFilterInterceptor.java:40) at > > org.apache.cxf.binding.soap.interceptor.SoapHeaderOutFilterInterceptor.h > > andleMessage(SoapHeaderOutFilterInterceptor.java:29) at > > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorC > > hain.java:236) at > > org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:483) at > > org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:309) at > > org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:261) at > > org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73) at > > org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:124) > > at $Proxy290.createProgram100(Unknown Source) > > > > I can't find any other cxf jars except cxf-2.2.5.jar. > > Also can't change class loader to "PARENT_LAST" because the app > > infrastructure requires "PAREAN_FIRST". > > Any suggstion to work around it? -- Daniel Kulp [email protected] - http://dankulp.com/blog Talend Community Coder - http://coders.talend.com
