You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by ajaysam <aj...@gmail.com> on 2013/06/05 05:48:16 UTC

Setting SOAPHeaders for CXF Endpoint using Processor

I am having problems while setting SOAPHeader using camel processor
the main objective of this flow is expose REST endpoint, get the REST
request, convert it to SOAP message, set SOAP headers and make SOAP request,
after getting the response, convert it back to REST json. And I am facing
problem is setting SOAP headers. 

My flow is as follows:

Camel is exposing a CXF-REST  endpoint.
The call comes in successfully.
It goes to processor.
The processor extracts the Query Parameters and creates another POJO object. 
- which represents a SOAP Request object.
The processor also creates a SOAP Header and sets it as shown below
---------------------------
 List<SoapHeader> soapHeaders =
CastUtils.cast((List<?>)exchg.getIn().getHeader(Header.HEADER_LIST));
        if (soapHeaders == null) {
            // we just create a new soap headers in case the header is null
            soapHeaders = new ArrayList<SoapHeader>();
        }
        
        // 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>New_testOobHeader</name><value>New_testOobHeaderValue</value></outofbandHeader>";
        SoapHeader newHeader = new SoapHeader(new
QName("http://cxf.apache.org/outofband/Header"),
                       DOMUtils.readXml(new
StringReader(xml)).getDocumentElement());
        // make sure direction is OUT since it is a response message.
        newHeader.setDirection(Direction.DIRECTION_INOUT);
        //newHeader.setMustUnderstand(false);
        soapHeaders.add(newHeader);
        System.out.println("Added Header");
------------------------
The return from processor is directed to camel:soapjaxb

<camel:marshal>
	    		<camel:soapjaxb version="1.1"
contextPath="com.bms.icc.cmeh.cmehindividualread"></camel:soapjaxb>
	    	</camel:marshal>
----------------------
Marshalling works and request pojo object is properly converted to soapBody
But I dont see header when i log the camel body and headers before making
soap call through cxf endpoint

Where am i going wrong?




--
View this message in context: http://camel.465427.n5.nabble.com/Setting-SOAPHeaders-for-CXF-Endpoint-using-Processor-tp5733829.html
Sent from the Camel - Users mailing list archive at Nabble.com.