You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Jean-Marc Taillant <ta...@bst.bsf.alcatel.fr> on 2002/09/10 09:25:40 UTC

SOAP Header, addHeader method

Hi all,

I saw that there was a problem in SOAP header and with addHeader() method from SOAPEnvelop class. Someone could tell me if this will be corrected in the next nightly release (09/10/2002)? This problem is very critic for our project.

Best regards,

Jean Marc Taillant



Re: SOAP Header, addHeader method

Posted by Jean-Marc Taillant <ta...@bst.bsf.alcatel.fr>.
I will try the last build from 2002/09/09



----- Original Message -----
From: "Davanum Srinivas" <di...@yahoo.com>
To: <ax...@xml.apache.org>
Sent: Tuesday, September 10, 2002 2:22 PM
Subject: Re: SOAP Header, addHeader method


> Fixed. Please cross-check with latest nightly build.
>
> -- dims
>
> --- Jean-Marc Taillant <ta...@bst.bsf.alcatel.fr> wrote:
> > Hi,
> > I joined the mail from the mailing list about the addHeader problem
> >
> > ----------------------------------------------------------------------
> > Ricky,
> > That helped quite a bit -- thanks. I tracked down the problem. First,
the
> > reason I wasn't able to see the .addHeader method on the SOAPEnvelope
object
> > is because the class I'm in (a holdover) imported
> > javax.xml.soap.SOAPEnvelope. So when I made a call to
> > SOAPEnvelope envelope =
msgContext.getRequestMessage().getSOAPEnvelope();
> >
> > It was really returning a javax.xml.soap.SOAPEnvelope object not an
> > org.apache.axis.message.SOAPEnvelope. I didn't have to cast it, nor did
I
> > get compile time errors because the Axis IMPL is a subclass of the Sun
> > interface. As a result the method addHeader() wasn't found.
> >
> > So since I couldn't use addHeader(), the road I was going down was to
call
> > addChildElement on the returned SOAPEnvelope object -- which in this
case
> > was javax.xml.soap.SOAPEnvelope -- but the implementation is actually in
the
> > parent class of org.apache.axis.message.SOAPEnvelope:
> > org.apache.axis.message.MessageElement.
> >
> > Now, I've looked through the source code for both the axis
MessageElement
> > object and the SOAPEnvelope object, and it seems like the code for
> > addChildElement is stubbed out. However, if I use the addChildElement()
call
> > instead of the addHeader() call, the element is not appended and my
> > modification doesn't take -- no error is thrown but the SOAP request
isn't
> > changed.
> >
> > The bug here is that both the org.apache.axis.message.SOAPHeader class
and
> > the org.apache.axis.message.SOAPBody class don't override the
> > addChildElement of their parent. If you look at the code for both of
these
> > classes, you'll see that they have a addHeaderElement() and
addBodyElement()
> > respectively. SOAPEvenlope has a similar behavior. But none of the 3
> > sub-classes override the parent class's method so the header, envelope
or
> > body is never really changed.
> >
> > The solution to this (bug?) is for the SOAPHeader, SOAPBody and
SOAPEnvelope
> > classes to override the addChildElement of the parent so that the
element
> > doesn't go in the generic "children" ArrayList in the MessageElement
parent
> > class but get added to the nested "bodyElements" Vector (in SOAPBody)
and
> > "headers" Vector (in SOAPHeader). I'd be happy to help the Axis
developers
> > with this change if necessary.
> >
> > Regards,
> > Rob
> >
> >
> >
> >
> > -----Original Message-----
> > From: Ricky Ho [mailto:riho@cisco.com]
> > Sent: Friday, September 06, 2002 10:54 AM
> > To: axis-user@xml.apache.org
> > Subject: RE: Handlers and SOAP message re-writing
> >
> >
> > Following is my exact code based on AXIS beta 2
> >
> > import org.apache.axis.*;
> > import org.apache.axis.handlers.*;
> > import org.apache.axis.message.*;
> >
> > public class PutHeaderHandler extends BasicHandler {
> >     public void invoke(MessageContext msgContext) throws AxisFault
> >     {
> >         try {
> >                 System.out.println(" -- PutHeaderHandler starts --");
> >                 System.out.println("Options are :  " + getOptions());
> >
> >                 SOAPEnvelope envelope =
> > msgContext.getRequestMessage().getSOAPEnvelope();
> >                 System.out.println("Request message is : " + envelope);
> >                 envelope.addHeader(new
SOAPHeaderElement("TestNameSpace",
> > "isAuthenticated", new Boolean(true)));
> >
> >                 System.out.println("Add header");
> >        } catch (Exception e) {
> >             throw AxisFault.makeFault(e);
> >         }
> >     }
> > }
> >
> > Rgds, Ricky
> > -----------------------------------------
> >
>
>
> =====
> Davanum Srinivas - http://xml.apache.org/~dims/
>
> __________________________________________________
> Yahoo! - We Remember
> 9-11: A tribute to the more than 3,000 lives lost
> http://dir.remember.yahoo.com/tribute


Re: SOAP Header, addHeader method

Posted by Davanum Srinivas <di...@yahoo.com>.
Fixed. Please cross-check with latest nightly build.

-- dims

--- Jean-Marc Taillant <ta...@bst.bsf.alcatel.fr> wrote:
> Hi,
> I joined the mail from the mailing list about the addHeader problem
> 
> ----------------------------------------------------------------------
> Ricky,
> 	That helped quite a bit -- thanks. I tracked down the problem. First, the
> reason I wasn't able to see the .addHeader method on the SOAPEnvelope object
> is because the class I'm in (a holdover) imported
> javax.xml.soap.SOAPEnvelope. So when I made a call to
> 		SOAPEnvelope envelope = msgContext.getRequestMessage().getSOAPEnvelope();
> 
> It was really returning a javax.xml.soap.SOAPEnvelope object not an
> org.apache.axis.message.SOAPEnvelope. I didn't have to cast it, nor did I
> get compile time errors because the Axis IMPL is a subclass of the Sun
> interface. As a result the method addHeader() wasn't found.
> 
> So since I couldn't use addHeader(), the road I was going down was to call
> addChildElement on the returned SOAPEnvelope object -- which in this case
> was javax.xml.soap.SOAPEnvelope -- but the implementation is actually in the
> parent class of org.apache.axis.message.SOAPEnvelope:
> org.apache.axis.message.MessageElement.
> 
> Now, I've looked through the source code for both the axis MessageElement
> object and the SOAPEnvelope object, and it seems like the code for
> addChildElement is stubbed out. However, if I use the addChildElement() call
> instead of the addHeader() call, the element is not appended and my
> modification doesn't take -- no error is thrown but the SOAP request isn't
> changed.
> 
> The bug here is that both the org.apache.axis.message.SOAPHeader class and
> the org.apache.axis.message.SOAPBody class don't override the
> addChildElement of their parent. If you look at the code for both of these
> classes, you'll see that they have a addHeaderElement() and addBodyElement()
> respectively. SOAPEvenlope has a similar behavior. But none of the 3
> sub-classes override the parent class's method so the header, envelope or
> body is never really changed.
> 
> The solution to this (bug?) is for the SOAPHeader, SOAPBody and SOAPEnvelope
> classes to override the addChildElement of the parent so that the element
> doesn't go in the generic "children" ArrayList in the MessageElement parent
> class but get added to the nested "bodyElements" Vector (in SOAPBody) and
> "headers" Vector (in SOAPHeader). I'd be happy to help the Axis developers
> with this change if necessary.
> 
> Regards,
> 	Rob
> 
> 
> 
> 
> -----Original Message-----
> From: Ricky Ho [mailto:riho@cisco.com]
> Sent: Friday, September 06, 2002 10:54 AM
> To: axis-user@xml.apache.org
> Subject: RE: Handlers and SOAP message re-writing
> 
> 
> Following is my exact code based on AXIS beta 2
> 
> import org.apache.axis.*;
> import org.apache.axis.handlers.*;
> import org.apache.axis.message.*;
> 
> public class PutHeaderHandler extends BasicHandler {
>     public void invoke(MessageContext msgContext) throws AxisFault
>     {
>         try {
>                 System.out.println(" -- PutHeaderHandler starts --");
>                 System.out.println("Options are :  " + getOptions());
> 
>                 SOAPEnvelope envelope =
> msgContext.getRequestMessage().getSOAPEnvelope();
>                 System.out.println("Request message is : " + envelope);
>                 envelope.addHeader(new SOAPHeaderElement("TestNameSpace",
> "isAuthenticated", new Boolean(true)));
> 
>                 System.out.println("Add header");
>        } catch (Exception e) {
>             throw AxisFault.makeFault(e);
>         }
>     }
> }
> 
> Rgds, Ricky
> -----------------------------------------
> 


=====
Davanum Srinivas - http://xml.apache.org/~dims/

__________________________________________________
Yahoo! - We Remember
9-11: A tribute to the more than 3,000 lives lost
http://dir.remember.yahoo.com/tribute

Re: SOAP Header, addHeader method

Posted by Jean-Marc Taillant <ta...@bst.bsf.alcatel.fr>.
Hi,
I joined the mail from the mailing list about the addHeader problem

----------------------------------------------------------------------
Ricky,
	That helped quite a bit -- thanks. I tracked down the problem. First, the
reason I wasn't able to see the .addHeader method on the SOAPEnvelope object
is because the class I'm in (a holdover) imported
javax.xml.soap.SOAPEnvelope. So when I made a call to
		SOAPEnvelope envelope = msgContext.getRequestMessage().getSOAPEnvelope();

It was really returning a javax.xml.soap.SOAPEnvelope object not an
org.apache.axis.message.SOAPEnvelope. I didn't have to cast it, nor did I
get compile time errors because the Axis IMPL is a subclass of the Sun
interface. As a result the method addHeader() wasn't found.

So since I couldn't use addHeader(), the road I was going down was to call
addChildElement on the returned SOAPEnvelope object -- which in this case
was javax.xml.soap.SOAPEnvelope -- but the implementation is actually in the
parent class of org.apache.axis.message.SOAPEnvelope:
org.apache.axis.message.MessageElement.

Now, I've looked through the source code for both the axis MessageElement
object and the SOAPEnvelope object, and it seems like the code for
addChildElement is stubbed out. However, if I use the addChildElement() call
instead of the addHeader() call, the element is not appended and my
modification doesn't take -- no error is thrown but the SOAP request isn't
changed.

The bug here is that both the org.apache.axis.message.SOAPHeader class and
the org.apache.axis.message.SOAPBody class don't override the
addChildElement of their parent. If you look at the code for both of these
classes, you'll see that they have a addHeaderElement() and addBodyElement()
respectively. SOAPEvenlope has a similar behavior. But none of the 3
sub-classes override the parent class's method so the header, envelope or
body is never really changed.

The solution to this (bug?) is for the SOAPHeader, SOAPBody and SOAPEnvelope
classes to override the addChildElement of the parent so that the element
doesn't go in the generic "children" ArrayList in the MessageElement parent
class but get added to the nested "bodyElements" Vector (in SOAPBody) and
"headers" Vector (in SOAPHeader). I'd be happy to help the Axis developers
with this change if necessary.

Regards,
	Rob




-----Original Message-----
From: Ricky Ho [mailto:riho@cisco.com]
Sent: Friday, September 06, 2002 10:54 AM
To: axis-user@xml.apache.org
Subject: RE: Handlers and SOAP message re-writing


Following is my exact code based on AXIS beta 2

import org.apache.axis.*;
import org.apache.axis.handlers.*;
import org.apache.axis.message.*;

public class PutHeaderHandler extends BasicHandler {
    public void invoke(MessageContext msgContext) throws AxisFault
    {
        try {
                System.out.println(" -- PutHeaderHandler starts --");
                System.out.println("Options are :  " + getOptions());

                SOAPEnvelope envelope =
msgContext.getRequestMessage().getSOAPEnvelope();
                System.out.println("Request message is : " + envelope);
                envelope.addHeader(new SOAPHeaderElement("TestNameSpace",
"isAuthenticated", new Boolean(true)));

                System.out.println("Add header");
       } catch (Exception e) {
            throw AxisFault.makeFault(e);
        }
    }
}

Rgds, Ricky
-----------------------------------------


Re: SOAP Header, addHeader method

Posted by Davanum Srinivas <di...@yahoo.com>.
Jean,

We (at least i) have no idea what you are talking about. The process is that you have to open up a
bugzilla bug at http://nagoya.apache.org with all relevant information so that one of us can work
on it and update the status of the bug as necessary.....

Thanks,
dims

--- Jean-Marc Taillant <ta...@bst.bsf.alcatel.fr> wrote:
> Hi all,
> 
> I saw that there was a problem in SOAP header and with addHeader() method from SOAPEnvelop
> class. Someone could tell me if this will be corrected in the next nightly release (09/10/2002)?
> This problem is very critic for our project.
> 
> Best regards,
> 
> Jean Marc Taillant
> 
> 
> 


=====
Davanum Srinivas - http://xml.apache.org/~dims/

__________________________________________________
Yahoo! - We Remember
9-11: A tribute to the more than 3,000 lives lost
http://dir.remember.yahoo.com/tribute