Thanks for your reply Glen. I'll code up an interceptor as you suggested to
see what's going on. I looks all OK on the wire. 
But I don't think that I'm reading the protocol header because
'responseMessageContext.get(Header.HEADER_LIST)' returns almost everything
one would expect: the correct localName of the element in the soap header 
(correlationId), the correct namespace of the element
(http://webservices.evilcom.com/header-v1) etc., only when I get the value
of the said element do I get a null value.

chriss




Glen Mazza wrote:
> 
> Hmmm...are you mixing up SOAP headers with HTTP headers--it seems you're
> creating the former but trying to query the latter, that might be the
> problem.
> 
> If it helps with debugging, you can attach JAX-WS Handlers[1] (or CXF
> interceptors[2]) to either the web service provider or the client and try
> to read the SOAP (HTTP?) headers there.  Wireshark[3] can also help in
> making sure that what you're looking for is indeed on the wire.
> 
> HTH,
> Glen
> 
> [1] http://www.jroller.com/gmazza/entry/jaxws_handler_tutorial
> [2] http://www.jroller.com/gmazza/entry/jaxwshandlers_to_cxfinterceptors
> [3] http://www.jroller.com/gmazza/entry/soap_calls_over_wireshark
> 
> 
> cstreiff wrote:
>> 
>> 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-tp28667390p28680283.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to