Hi,
OK, in Camel 1.x , you can get the CXF Message directly from the exchange
CxfMessage cxfMessage = (CxfMessage) exchange.getIn();
org.apache.cxf.message.Message message = cxfMessage.getMessage();
List<org.apache.cxf.headers.Header> heads =
message.get(org.apache.cxf.headers.Header.HEADER_LIST));
, then you can read the header from the list.
Willem
kav m wrote:
Hi Willem,
Thanks a lot for your response !
I tried to use the option '-exsh true' for wsdl2java and regenerated the
code after doing a clean. But I am still getting the same error as before.
The way I am using the wsdl2java cxf plugin in my pom with the exsh option
is as follows:
<!-- CXF wsdl2java generator, will plugin to the compile goal -->
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf-version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdl/NotificationService.wsdl</wsdl>
<extraargs>
<extraarg>-exsh</extraarg>
<extraarg>true</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
Is this correct ?
At this point I do not want to use the dataFormat=PAYLOAD option or the
WebServiceProviderAPI to get the SOAP Headers and it would be great if using
exsh=true works for me...
Any suggestions ?
Thanks a lot !
Kavita
willem.jiang wrote:
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