You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Gabriel <ga...@online.de> on 2013/01/18 15:25:40 UTC

add custom soap-header from pojo message

Hi,
I have a Problem with cxf soap-headers. I set up an cxf-project with the
Contract-firs-development method. I want to call a web service with an
cxf-component which uses a wsld:
_____________________________________________________________________
<cxf:cxfEndpoint id="ICCSCustomerService"
                    
address="http://localhost:8080/iccs-xsoap/CustomerService/updateCustomer"
                    
serviceClass="de.iccs.xsoap.customer.v1.CustomerServiceImpl"
                     wsdlURL="wsdl/CustomerService.wsdl">
    </cxf:cxfEndpoint>
______________________________________________________________________
I want to send an pojo throw an queue as an request for the ws. But I need
to implement a soap header like this one:
______________________________________________________________________
<ns2:Header>
	<simpleAuth xmlns="http://xsoap.iccs.de/v1" password="s2m3s"
username="admin"/>
</ns2:Header>
______________________________________________________________________
To archive this I wrote an processor like this one:
______________________________________________________________________
   @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=\"yyy\" password=\"xxx\"
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);
______________________________________________________________________
My route looks like this:
______________________________________________________________________
<route id="CustomerServiceUpdateCustomerTest">
            <camel:from uri="direct:iccsUpdateCustomerRequest"/>
            <camel:process ref="addCredentials"/>
                       <to uri="cxf:bean:ICCSCustomerService"/> 
            <camel:to uri="stream:out"/>
        </route>

Unfortunatly I get an null-pointer Exception in this  statement:
           List<SoapHeader> soapHeaders =
CastUtils.cast((List<?>)exchange.getOut().getHeader(Header.HEADER_LIST));
Obviously there are no soap-headers in this message. And it seems not to be
an soap message at all.
Even an 
           <camel:marshal>
                <soapjaxb contextPath="de.iccs.xsoap.customer.v1" />
            </camel:marshal>
            <camel:process ref="addCredentials"/>
does not work, as it produces only an soap-envelope without an soap-header. 

 Could you provide me an example how to get an soap message (with
soap-header) from an pojo-message.
Thank you 
Gabriel




--
View this message in context: http://camel.465427.n5.nabble.com/add-custom-soap-header-from-pojo-message-tp5725764.html
Sent from the Camel - Users mailing list archive at Nabble.com.