You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Daniel Kulp <dk...@apache.org> on 2010/06/01 17:30:04 UTC

Re: response message soap header reading problem

Actually, I don't think it really is null.   If you look at the log for the 
line:

log.info("header="+hr.getObject());

you see:

(btpool0-4:) header=[correlationId: null]

That is actually how the Xerces DOM would look on a toString.   The Xerces 
toString impl is pathetic.    I'm willing to be if you do:

Element el = (Element) hr.getObject();
String cid = el.getTextContent();

then the cid is there.

Dan




On Monday 31 May 2010 8:51:24 am cstreiff wrote:
> Glen,
> 
> I'm now using interceptors, but the Problem persists. The name, ns, etc. of
> the soap header element is returned correctly, however I always get null
> for the elment value:
> hader=[correlationId: null]
> headerName={http://webservices.evilcom.com/header-v1}correlationId
> 
> Does anyone have any idea where I'm going wrong. It must be a fairly
> fundamental mistake that I'm making, having changed to interceptors and
> still experiencing the same problem.
> 
> Here is the response message on the wire with header and all:
> 
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
>    <soap:Header>
>       <correlationId
> xmlns="http://webservices.evilcom.com/header-v1">666</correlationId>
>    </soap:Header>
>    <soap:Body>
>       <ns2:serviceResponse
> xmlns:ns2="http://evil.evilcom.com/schema/spr/v1_1/local">
>          <serviceReturn>
>             <code>ACK</code>
>          </serviceReturn>
>       </ns2:serviceResponse>
>    </soap:Body>
> </soap:Envelope>
> 
> 
> The InInterceptor:
> 
> public class SoapHeaderInInterceptor3 extends  AbstractSoapInterceptor{
> 
> 	public static final  QName CORRELATION_ID_ELEMENT =
>         new QName("http://webservices.evilcom.com/header-v1",
> "correlationId");
> 
> 
> 	public SoapHeaderInInterceptor3() {
> 		super(Phase.READ);
>         addAfter(ReadHeadersInterceptor.class.getName());
>         addAfter(EndpointSelectionInterceptor.class.getName());
> 
> 	}
> 
> 	final Logger log =
> LoggerFactory.getLogger(SoapHeaderInInterceptor3.class);
> 
> 	public void handleMessage(SoapMessage message) throws Fault {
> 
> 		List<Header> hl = message.getHeaders();
> 		for(Header hr : hl) {
> 			log.info("header="+hr.getObject());
> 			log.info("headerName="+hr.getName());
> 		}
> 	}
> 
> 
> The relevant logfile parts:
> 
> 2010-05-31 14:42:33,991 114738 INFO
> [org.apache.cxf.interceptor.LoggingInInterceptor] (btpool0-4:) Inbound
> Message
> ----------------------------
> ID: 2
> Response-Code: 200
> Encoding: UTF-8
> Content-Type: text/xml; charset=utf-8
> Headers: {Content-Length=[370], 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><correl
> ationId
> xmlns="http://webservices.evilcom.com/header-v1">666</correlationId></soap
> :Header><soap:Body><ns2:serviceResponse
> xmlns:ns2="http://sptil.evilcom.com/schema/spr/v1_1/local"><serviceReturn>
> <code>ACK</code></serviceReturn></ns2:serviceResponse></soap:Body></soap:En
> velope> --------------------------------------
> 2010-05-31 14:42:33,992 114739 INFO
> [com.evilcom.aaa.mockserviceprofile.sprovider.SoapHeaderInInterceptor3]
> (btpool0-4:) header=[correlationId: null]
> 2010-05-31 14:42:33,992 114739 INFO
> [com.evilcom.aaa.mockserviceprofile.sprovider.SoapHeaderInInterceptor3]
> (btpool0-4:)
> headerName={http://webservices.evilcom.com/header-v1}correlationId
> 
> 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.

-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog

Re: response message soap header reading problem

Posted by cstreiff <ch...@streiff.org>.
Hi Dan,

excellent, you're absolutely right! It worked just the way you said it
would. 

Thank you very much for your answer and for saving me another sleepless
night.
chriss

 


Actually, I don't think it really is null.   If you look at the log for the 
line:

log.info("header="+hr.getObject());

you see:

(btpool0-4:) header=[correlationId: null]

That is actually how the Xerces DOM would look on a toString.   The Xerces 
toString impl is pathetic.    I'm willing to be if you do:

Element el = (Element) hr.getObject();
String cid = el.getTextContent();

then the cid is there.

Dan

-- 
View this message in context: http://old.nabble.com/response-message-soap-header-reading-problem-tp28667390p28744374.html
Sent from the cxf-user mailing list archive at Nabble.com.