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

Reply via email to