geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ivan <>
Subject Re: SOAPMessage.getSOAPHeaders() return null while no headers in the soap envelope
Date Mon, 11 Apr 2011 08:41:01 GMT
Seems that axiom optimize the serialization, if no sub header element
exists, it will not output header element.
if ((header != null) && (header.getFirstOMChild() != null)) {
                    serializeInternally((OMNodeImpl) header, writer);

2011/4/11 Ivan <>

> Hi, I am running Axis2 on Geronimo 3.0, and in the latest JAX-WS TCK
> testing, I got a NPE for some cases. The cause for it is that some cases
> will check whether those elements are not in the SOAP headers, while those
> soap message has no header element.
> From the Java doc of SOAPMessage, it writes :
> getSOAPHeader
> public SOAPHeader <http://j2ee6/api/javax/xml/soap/SOAPHeader.html> *getSOAPHeader*()
>                          throws SOAPException <http://j2ee6/api/javax/xml/soap/SOAPException.html>
> Gets the SOAP Header contained in this SOAPMessage object.
>  *Returns:* the SOAPHeader object contained by this SOAPMessage object *
> Throws:* SOAPException - if the SOAP Header does not exist or cannot be
> retrieved *Since:* SAAJ 1.2
> From the Java Doc of SOAPEnvelop, it wirtes:
> getHeader
> SOAPHeader <http://j2ee6/api/javax/xml/soap/SOAPHeader.html> *getHeader*()
>                      throws SOAPException <http://j2ee6/api/javax/xml/soap/SOAPException.html>
> Returns the SOAPHeader object for this SOAPEnvelope object.
> A new SOAPMessage object is by default created with a SOAPEnvelope object
> that contains an empty SOAPHeader object. As a result, the method
> getHeader will always return a SOAPHeader object unless the header has
> been removed and a new one has not been added.
>  *Returns:* the SOAPHeader object or null if there is none *Throws:*
> SOAPException - if there is a problem obtaining the SOAPHeader object
> It seems that there is different behavior for SOAPMessage.getSOAPHeader()
> and SOAPEnvelop.getHeader(). and in current axis2-saaj implementation, it
> always returns null while no header element exists.
> Personally, I thought it is an issue of saaj spec, it is not user-friendly
> to throw an exception while no header exists. Actually, I also test this
> with the ri saaj implementation, and it seems to have the same behavior with
> axis2-saaj.
> Another possible solution is to add an empty header element for those soap
> message if no header element exists, I could see it could be done in the
> SAAJConverter.
> Thoughts ?
> thanks.
> --
> Ivan


View raw message