It looks like you want to set the cxf message header before routing the request 
to the camel-cxf endpoint.
As you know, camel message header doesn't any thing know about the CXF message 
headers information before routing the message into the CXF endpoint.
That could explain why you get the NPE.  
If you want to add the customer SOAP header for the cxf endpoint, you can just 
create a new List of SoapHeader, and set it into camel message header with the 
key Header.HEADER_LIST like this

List<SoapHeader> soapHeaders = new ArrayList<SoapHeader>();
……
exchange.getOut().setHeader(Header.HEADER_LIST, soapHeaders);


--  
Willem Jiang

Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) 
(English)
          http://jnn.iteye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem




On Monday, January 28, 2013 at 9:03 PM, Gabriel wrote:

> Hi,
> I want to add a custom SOAP-Header to a pojo message. For that I configured
> the following route:
>  
> <route id="CustomerServiceUpdateCustomerTest">
> <camel:from uri="direct:iccsUpdateCustomerRequest"/>
> <camel:process ref="addCredentials"/>
> <to uri="cxf:bean:ICCSCustomerService"/>  
> </route>
>  
> The Header should be inserted by the processor witch looks like that:
> @Override  
> public void process(Exchange exchange) throws Exception {  
> List<SoapHeader> soapHeaders =
> CastUtils.cast((List<?)exchange.getOut().getHeader(Header.HEADER_LIST));  
> // Insert a new header  
> String xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><outofbandHeader
> &quot;  
> + &quot;xmlns=\&quot;http://cxf.apache.org/outofband/Header\&quot;
> hdrAttribute=\&quot;testHdrAttribute\&quot; &quot;  
> +
> &quot;xmlns:soap=\&quot;http://schemas.xmlsoap.org/soap/envelope/\&quot;
> soap:mustUnderstand=\&quot;1\&quot;>"  
> + "<name>simpleAuth username=\"xxx\" password=\"abc\"
> xmlns=\"http://xsoap.iccs.de/v1\";</name></outofbandHeader>";  
>  
> SoapHeader newHeader = new SoapHeader(new
> QName("http://xsoap.iccs.de/v1";, "simpleAuth"),  
> DOMUtils.readXml(new
> StringReader(xml)).getDocumentElement());  
> // make sure direction is OUT since it is a response message.  
> newHeader.setDirection(Direction.DIRECTION_OUT);  
> //newHeader.setMustUnderstand(false);  
> soapHeaders.add(newHeader);  
> }
>  
>  
> CastUtils.cast((List<?)exchange.getOut().getHeader(Header.HEADER_LIST));  
> throws a npe.  
> This should be the correct way to insert an custom Soap-Header. What's
> wrong?
> Can someone help me which that?
>  
> Thanks Gabriel
>  
>  
>  
>  
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/insert-custom-Soap-Header-problem-tp5726415.html
> Sent from the Camel - Users mailing list archive at Nabble.com 
> (http://Nabble.com).



Reply via email to