Hi
CXF supports to map the message header into the SEI's opteraion
parameter, but you need to enable this by passing the option "-exsh
true" into WSDL2Java.
If you want to a more general way to get the SOAP header, you try the
WebServiceProvider API[1] or PAYLOAD dataformat[2]
[1]
http://camel.apache.org/cxf-example.html#CXFExample-CXFexampleforusingtheWebServiceProviderAPI
[2]http://camel.apache.org/cxf.html#CXF-HowtodealwiththemessageforacamelcxfendpointinPAYLOADdataformat
Willem
kav m wrote:
Hi,
I am using camel 1.6 and have a cxf web service endpoint which receives a
SOAP request. I need to extract the SOAP Headers out of this request. I
tried to use the following code:
----------------------------code I
used---BEGIN----------------------------------------
Map<String, Object> headers = arg0.getIn().getHeaders(); //1
System.out.println("MAP Headers size= " + headers.size()); //2
List<SoapHeader> soapHeaders = (List<SoapHeader>)
headers.get(Header.HEADER_LIST); //3
System.out.println("Headers size= " + soapHeaders.size()); //4
Element header;
String headerName;
Iterator<SoapHeader> iter = soapHeaders.iterator();
while (iter.hasNext()) {
header = (Element) iter.next().getObject();
System.out.println("Header namespace = " +
header.getNamespaceURI());
headerName = header.getFirstChild().getNodeValue();
System.out.println("Header name = " + headerName);
}
----------------------------code I
used---END----------------------------------------------
In the above code, Line no. 2 i.e. the Map headers has a size of 8 and
contains some key:value pairs like content-type:text/xml ,
operationName:Subscribe , which look like headers coming from the
annotations used by my service interface.I don't see the actual soapHeaders
present in my soap request.
Also, at Line No. 3, the List soapHeaders is showing as 'null' and thus, I'm
getting a null pointer at Line no. 4
My Soap Request :
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:b="http://docs.oasis-open.org/wsn/b-2"
xmlns:rim="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0"
xmlns:add="http://www.w3.org/2005/08/addressing">
<soapenv:Header>
<add:Action>http://docs.oasis-open.org/wsn/bw-2/NotificationProducer/SubscribeRequest</add:Action>
<add:MessageID>382dcdc7-8e84-9fdc-8443-48fd83bca938</add:MessageID>
</soapenv:Header>
<soapenv:Body>
<b:Subscribe>
.
.
.
.
.
</b:Subscribe>
</soapenv:Body>
</soapenv:Envelope>
What I am looking for is to extract the headers 'Action' and 'MessageID'
(using dataFormat=POJO)
Can someone pls help me achieve that ?
Thanks a lot !
Kavita