Hi,
Summary:
Adding a header to a soap message using the WebServiceContext is working
fine. However, reading the header using the reverse procedure fails.
Environment:
CXF 2.2.7, OSX and GNU Linux
Problem Description:
1) I'm adding the Header:
...
List<Header> headers = new ArrayList<Header>();
Header cidHeader;
try {
cidHeader = new Header(CORRELATION_ID_ELEMENT, cid, new
JAXBDataBinding(String.class));
} catch (JAXBException e) {
throw new IllegalArgumentException("SOAP Header JAXB binding is
broken and needs to be fixed.", e);
}
headers.add(cidHeader);
ctx.put(Header.HEADER_LIST, headers); // WebServiceContext
...
2) and when I look at the service consumers logfile all seems to be OK. The
services response message contains the header:
2010-05-25 11:13:46,512 33093 INFO
[org.apache.cxf.interceptor.LoggingInInterceptor] (btpool0-3:) Inbound
Message
----------------------------
ID: 2evilcom
Response-Code: 200
Encoding: UTF-8
Content-Type: text/xml; charset=utf-8
Headers: {Content-Length=[403], Server=[Jetty(6.1.1rc1)],
content-type=[text/xml; charset=utf-8]}
Payload: <soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header><correlationId
xmlns="http://webservices.evilcom.com/header-v1">ff7818d7-60ab-40a2-b594-28515b1007f2</correlationId></soap:Header><soap:Body>....</soap:Body></soap:Envelope>
--------------------------------------
3) Now I'm trying to read the header and all I get is the (local) name of
the header element and a null value:
public CommonSoapHeader(Map<String, Object> requestMessageContext,
Map<String, Object> responseMessageContext) {
log.info("responseMessageContext=" + responseMessageContext);
List<Header> headers =
(List<Header>)responseMessageContext.get(Header.HEADER_LIST);
if(headers == null) { throw new NullPointerException("Unexpected
error: message context should have returned a header list."); }
for(Iterator<Header> i = headers.iterator(); i.hasNext();) {
Header h = i.next();
Element n = (Element)h.getObject();
log.info("lname="+n.getLocalName());
log.info("nv="+ n.getNodeValue());
}
}
getLocalName() yields the expected element name 'correlationId', however
'getNodeValue()' always yields 'null'.
4) It seems that I'm making a mistake along the way. Why am I always getting
a null value for my header element?
I would greatly appreciate a hint on where I went wrong.
chriss
--
View this message in context:
http://old.nabble.com/response-message-soap-header-reading-problem-tp28667390p28667390.html
Sent from the cxf-user mailing list archive at Nabble.com.