Hi, Thx, that was it. Unfortunately I can't use your preferred solution because I'm porting a legacy JAX-RPC handler and I need to reuse an abstract class. The class in question generates a SOAPElement and then in JAX-RPC, it was appended using
*header.addChildElement(soapElement);* I'm replicating the exact behavior in CXF/JAX-WS but SOAPOutInterceptor is throwing an exception in the *writeSoapEnvelopeStart(message);* method (same problem I was facing when using the jaxws handler): *Caused by: org.w3c.dom.DOMException: HIERARCHY_REQUEST_ERR: An attempt was made to insert a node where it is not permitted* Is there any problem I'm not aware of here? How should I add an element to the header tag? Regards On Wed, Mar 21, 2012 at 2:53 PM, Daniel Kulp <[email protected]> wrote: > On Wednesday, March 21, 2012 02:09:56 PM Jose Noheda wrote: > > Hi, > > > > Looking at > > http://www.jroller.com/gmazza/entry/jaxwshandlers_to_cxfinterceptors it > > should be very simple to add a new header to a SOAP message. > > Unfortunately, my CXF message always return null when I ask for the > > SOAPMessage. Here's the code: > > > > * public SecurityOutInterceptor() { > > super(Phase.PRE_PROTOCOL); // Tried other Phases as well > > } > > > > protected SOAPHeader getSOAPHeader(SoapMessage message) throws > > SOAPException { > > SOAPMessage soapMessage = message.getContent(SOAPMessage.class); > > return soapMessage.getSOAPHeader(); > > }* > > > > It always throws a NullPointerException. I've tried using a Handler > > instead of an interceptor to no avail (*SoapOutInterceptor* throws an > > exception when wirting the envelope for some unkown reason). Can someone > > spot the problem? > > This would only work if you also configure in the SAAJOutInterceptors. By > default, we don't create the SOAPMessage unless asked for. > > The best option is to just do: > > message.getHeaders().add( > new Header(qname, domElement)); > > if you do that fairly early in the interceptor chain, the domElement would > be streamed out at the appropriate time. > > Dan > > > > > Any help is appreciatted, thanks in advance. > > > > Regards > > > > PS: The client is created > > > > <jaxws:client id="fooClientProxy" serviceClass="foo.Bar" > > address="..."> <jaxws:outInterceptors> > > <bean class="foo.BarOutInterceptor" /> > > </jaxws:outInterceptors> > > </jaxws:client> > -- > Daniel Kulp > [email protected] - http://dankulp.com/blog > Talend Community Coder - http://coders.talend.com > >
